private void UpdateHospitalEditForm(HospitalModel hospitalData) { testExecutioner.SetTextOnElement("hospitalName", hospitalData.HospitalName); testExecutioner.SetTextOnElement("street", hospitalData.Address); testExecutioner.SetTextOnElement("city", hospitalData.City); testExecutioner.SetTextOnElement("state", hospitalData.State); testExecutioner.ClickElement("saveBtn", "", "", "Enter hospital data, and click 'Save'", "Hospital data should be saved", true, 10); testExecutioner.Pause(500); }
public bool LoginToPMS(string username, string password) { executioner.SetTextOnElement("username", username); executioner.SetTextOnElement("password", password); executioner.Pause(1000); executioner.ClickElement("loginBtn", "", "", "Enter username and password, click the Login button", "", true, 10); return(executioner.DoesElementExist("ng-show", "invalidCredentials", "span", 3) == false); }
public void NavigateToExistingHosptialEdit(string hosptialName) { //This is a good example of where there isn't a good clean way to access an html element, and //you, as the test automator can't go to the devs and say 'add an id here' //In this example I'm trying to get the anchor tag for the Edit button for a specified hosptial //For example: $('div[ng-repeat*="hospital" h3:contains("Childrens") a') JQuerySelector script = new JQuerySelector("$('div[ng-repeat*=\"hospital\"] h3:contains(\"" + hosptialName + "\") a')"); executioner.ClickElement(script, "Click the Edit button for " + hosptialName + " hospital", "Should be taken to the hospital edit screen"); executioner.Pause(500); }
private ElementResult CompleteAction(ElementObject eleObj, ElementResult eleRes) { SelectElement select; var ele = eleRes.RawEle; var rsp = new ElementResult(TE) { Success = false, RawEle = ele, ElementName = eleObj.ElementName }; if (ele == null && !(eleObj.Action == ElementAction.Wait && eleObj.WaitType == Wait.Invisible)) { return(rsp); } if (eleObj.Random) { eleObj.Text = TE.Rand.GetRandomString(eleObj.RandomLength); } try { if (eleObj.Scroll) { try { rsp.ScrollTo(eleObj.ScrollLoc); } catch { try { //scroll till element is within the center 50% of the screen??????????? Just not sure how to drag.. //TouchActions action = new TouchActions(Driver); //var visibleText = "Submit"; //((AndroidDriver<IWebElement>)Driver).FindElementByAndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(\"" + visibleText + "\").instance(0))"); //TouchActions action = new TouchActions(Driver); //action.Scroll(ele, 10, 100).Perform(); } catch (Exception e) { Console.WriteLine(e.Message); } } // (((IWrapsDriver)ele).WrappedDriver as IJavaScriptExecutor).ScrollToElement(ele); } switch (eleObj.Action) { case ElementAction.Click: ele.Click(); break; case ElementAction.Hover: var act = new Actions(Driver); act.MoveToElement(ele).Build().Perform(); TE.Pause(150); //default pause for hover to take effect break; case ElementAction.EnterText: if (eleObj.Clear) { ele.Clear(); ele.SendKeys(Keys.Control + "a"); ele.SendKeys(Keys.Backspace); } ele.SendKeys(eleObj.Text); break; case ElementAction.Dropdown: if (eleObj.Random) { eleObj.Action = ElementAction.DropdownIndex; return(CompleteAction(eleObj, eleRes)); } select = new SelectElement(ele); if (select.IsMultiple && eleObj.Clear) { select.DeselectAll(); } rsp.Text = SetDropdown(select, eleObj.Text); break; case ElementAction.GetDropdown: select = new SelectElement(ele); if (select.IsMultiple) { var tempLst = new List <string>(); select.AllSelectedOptions.ToList().ForEach(x => tempLst.Add(x.Text)); rsp.Text = string.Join('|', tempLst); } else { rsp.Text = select.SelectedOption.Text; } break; case ElementAction.DropdownIndex: select = new SelectElement(ele); if (select.IsMultiple && eleObj.Clear) { select.DeselectAll(); } var start = eleObj.Text.Length > 1 ? 1 : 0; var index = TE.Rand.Rnd.Next(start, select.Options.Count); if (int.TryParse(eleObj.Text, out int indexVal) || !eleObj.Random) { index = indexVal; } select.SelectByIndex(index); rsp.Text = select.Options[index].Text; break; case ElementAction.MultiDropdown: select = new SelectElement(ele); if (select.IsMultiple && eleObj.Clear) { select.DeselectAll(); } foreach (var option in eleObj.Text.Split('|')) { SetDropdown(select, option); } break; case ElementAction.RadioBtn: if (!eleObj.Text.ToLower().Equals(ele.Selected.ToString().ToLower())) { ele.Click(); } break; case ElementAction.GetCheckbox: rsp.Text = ele.Selected.ToString(); break; case ElementAction.GetText: if (ele.TagName.Equals("select")) { select = new SelectElement(ele); if (select.IsMultiple) { var ops = new List <string>(); select.AllSelectedOptions.ToList().ForEach(x => ops.Add(x.Text)); rsp.Text = string.Join("\n", ops); } else { rsp.Text = select.SelectedOption.Text; } } else { rsp.Text = ele.Text; } if (string.IsNullOrEmpty(rsp.Text)) { rsp.Text = ele.GetAttribute("value"); } if (rsp.Text == null) { rsp.Text = ""; } break; case ElementAction.GetAttribute: rsp.Text = ele.GetAttribute(eleObj.Text); break; case ElementAction.GetCSS: rsp.Text = ele.GetCssValue(eleObj.Text); break; case ElementAction.GetProperty: rsp.Text = ele.GetProperty(eleObj.Text); break; case ElementAction.Wait: //nothing to do here break; default: throw new NotImplementedException("This action has not been implemented. Please implement it."); } } catch (Exception e) { rsp.Exception = e; rsp.Success = false; return(rsp); } rsp.Success = true; return(rsp); }