public void SelectFromDropdown() { ActGenElement act = new ActGenElement(); act.LocateBy = eLocateBy.ByID; act.GenElementAction = ActGenElement.eGenElementAction.SelectFromDropDown; act.LocateValueCalculated = "accountSubType"; act.Value = "EMPLOYEE"; act.Active = true; mBF.CurrentActivity.Acts.Add(act); mBF.CurrentActivity.Acts.CurrentItem = act; mGR.RunAction(act, false); act = new ActGenElement(); act.LocateBy = eLocateBy.ByID; act.GenElementAction = ActGenElement.eGenElementAction.GetValue; act.LocateValueCalculated = "accountSubType"; act.AddNewReturnParams = true; act.Active = true; mBF.CurrentActivity.Acts.Add(act); mBF.CurrentActivity.Acts.CurrentItem = act; mGR.RunAction(act, false); Assert.AreEqual(act.Status, eRunStatus.Passed, "Action Status"); string actual = act.GetReturnParam("Actual"); Assert.AreEqual(actual, "2", "True"); Assert.AreEqual(act.Error, null, "Act.Error"); }
public void GetValue_Textbox() { ActGenElement act = new ActGenElement(); act.LocateBy = eLocateBy.ByName; act.GenElementAction = ActGenElement.eGenElementAction.SetValue; act.LocateValueCalculated = "firstName"; act.Value = "Ginger"; act.Active = true; mBF.CurrentActivity.Acts.Add(act); mBF.CurrentActivity.Acts.CurrentItem = act; mGR.RunAction(act, false); act = new ActGenElement(); act.LocateBy = eLocateBy.ByName; act.GenElementAction = ActGenElement.eGenElementAction.GetValue; act.LocateValueCalculated = "firstName"; act.AddNewReturnParams = true; act.Active = true; mBF.CurrentActivity.Acts.Add(act); mBF.CurrentActivity.Acts.CurrentItem = act; mGR.RunAction(act, false); Assert.AreEqual(act.Status, eRunStatus.Passed, "Action Status"); string actual = act.GetReturnParam("Actual"); Assert.AreEqual(actual, "Ginger", "True"); Assert.AreEqual(act.Error, null, "Act.Error"); }
public void SwitchFrame_GenElement() { ActGenElement act = new ActGenElement(); act.LocateBy = eLocateBy.ByID; act.GenElementAction = ActGenElement.eGenElementAction.SwitchFrame; act.LocateValueCalculated = "accountSubType"; act.AddNewReturnParams = true; act.Active = true; mBF.CurrentActivity.Acts.Add(act); mBF.CurrentActivity.Acts.CurrentItem = act; mGR.Executor.RunAction(act, false); Assert.AreEqual(act.Status, eRunStatus.Passed, "Action Status"); string actual = act.GetReturnParam("Actual"); Assert.AreEqual(actual, "true", "True"); Assert.AreEqual(act.Error, null, "Act.Error"); }
public void GetElementAttribute_Dropdown() { ActGenElement act = new ActGenElement(); act.LocateBy = eLocateBy.ByID; act.GenElementAction = ActGenElement.eGenElementAction.GetElementAttributeValue; act.LocateValueCalculated = "accountSubType"; act.AddNewReturnParams = true; act.Value = "Ginger"; act.Active = true; mBF.CurrentActivity.Acts.Add(act); mBF.CurrentActivity.Acts.CurrentItem = act; mGR.RunAction(act, false); Assert.AreEqual(act.Status, eRunStatus.Passed, "Action Status"); string actual = act.GetReturnParam("Actual"); Assert.AreEqual(actual, "RETAILEMPLOYEEDEMOTESTDEALER EMPLOYEEVIPBUSINESSHOUSE", "True"); Assert.AreEqual(act.Error, null, "Act.Error"); }
public void GetStyle_Dropdown() { ActGenElement act = new ActGenElement(); act.LocateBy = eLocateBy.ByName; act.GenElementAction = ActGenElement.eGenElementAction.GetStyle; act.LocateValueCalculated = "accountSubType"; act.AddNewReturnParams = true; act.Value = "Ginger"; act.Active = true; mBF.CurrentActivity.Acts.Add(act); mBF.CurrentActivity.Acts.CurrentItem = act; mGR.RunAction(act, false); Assert.AreEqual(act.Status, eRunStatus.Passed, "Action Status"); string actual = act.GetReturnParam("Actual"); Assert.AreEqual(actual, "width: 140px;", "True"); Assert.AreEqual(act.Error, null, "Act.Error"); }
public void SendKeys_textbox() { ActGenElement act = new ActGenElement(); act.LocateBy = eLocateBy.ByName; act.GenElementAction = ActGenElement.eGenElementAction.Click; act.LocateValueCalculated = "ssnNumber"; act.Active = true; mBF.CurrentActivity.Acts.Add(act); mBF.CurrentActivity.Acts.CurrentItem = act; mGR.RunAction(act, false); act = new ActGenElement(); act.LocateBy = eLocateBy.ByName; act.GenElementAction = ActGenElement.eGenElementAction.SendKeys; act.LocateValueCalculated = "ssnNumber"; act.Value = "1234"; act.Wait = 4; act.Active = true; mBF.CurrentActivity.Acts.Add(act); mBF.CurrentActivity.Acts.CurrentItem = act; mGR.RunAction(act, false); act = new ActGenElement(); act.LocateBy = eLocateBy.ByName; act.GenElementAction = ActGenElement.eGenElementAction.GetValue; act.LocateValueCalculated = "ssnNumber"; act.AddNewReturnParams = true; act.Wait = 2; act.Active = true; mBF.CurrentActivity.Acts.Add(act); mBF.CurrentActivity.Acts.CurrentItem = act; mGR.RunAction(act, false); Assert.AreEqual(act.Status, eRunStatus.Passed, "Action Status"); string actual = act.GetReturnParam("Actual"); Assert.AreEqual(actual, "1234", "True"); Assert.AreEqual(act.Error, null, "Act.Error"); }
//Handle all Generic Actions public void GenElementHandler(ActGenElement act) { IWebElement e; switch (act.GenElementAction) { //Click and ClickAt case ActGenElement.eGenElementAction.ClickAt: case ActGenElement.eGenElementAction.Click: e = LocateElement(act); if (e == null) { act.Error = "Error: Element not found - " + act.LocateBy + " " + act.LocateValue; return; } else { e.Click(); } break; //Set Value case ActGenElement.eGenElementAction.SetValue: e = LocateElement(act); if (e != null) { if (e.TagName == "select") { SelectElement combobox = new SelectElement(e); string val = act.ValueForDriver; combobox.SelectByText(val); act.ExInfo += "Selected Value - " + val; return; } if (e.TagName == "input" && e.GetAttribute("type") == "checkbox") { ((IJavaScriptExecutor)Driver).ExecuteScript("arguments[0].setAttribute('checked',arguments[1])", e, act.ValueForDriver); return; } //Special case for FF if (Driver.GetType() == typeof(FirefoxDriver) && e.TagName == "input" && e.GetAttribute("type") == "text") { e.Clear(); e.SendKeys(GetKeyName(act.ValueForDriver)); } else { ((IJavaScriptExecutor)Driver).ExecuteScript("arguments[0].setAttribute('value',arguments[1])", e, act.ValueForDriver); } } else { act.Error = "Error: Element not found - " + act.LocateBy + " " + act.LocateValueCalculated; return; } break; //KeyType - similar to Keyboard Input case ActGenElement.eGenElementAction.KeyType: e = LocateElement(act); if (e != null) { e.Clear(); e.SendKeys(GetKeyName(act.ValueForDriver)); } else { act.Error = "Error: Element not found - " + act.LocateBy + " " + act.LocateValueCalculated; return; } break; //Keyboard Input - similar to KeyType case ActGenElement.eGenElementAction.KeyboardInput: e = LocateElement(act); if (e != null) { e.SendKeys(GetKeyName(act.ValueForDriver)); } else { act.Error = "Error: Element not found - " + act.LocateBy + " " + act.LocateValueCalculated; return; } break; //Check this case ActGenElement.eGenElementAction.GetValue: e = LocateElement(act); if (e != null) { act.AddOrUpdateReturnParamActual("Actual", e.GetAttribute("text")); if (act.GetReturnParam("Actual") == null) { act.AddOrUpdateReturnParamActual("Actual", e.Text); } } else { act.Error = "Error: Element not found - " + act.LocateBy + " " + act.LocateValue; return; } break; //GoToURL - implemented also as GoToURL action and not in GenElementHandler action case ActGenElement.eGenElementAction.GotoURL: string sURL = act.ValueForDriver.ToLower(); if (sURL.StartsWith("www")) { sURL = "http://" + act.ValueForDriver; } else { sURL = act.ValueForDriver; } Driver.Navigate().GoToUrl(sURL); break; //Wait Action case ActGenElement.eGenElementAction.Wait: WaitAction(act); break; //Delete all Cookies case ActGenElement.eGenElementAction.DeleteAllCookies: //TODO: FIXME: This action should not be part of GenElement Driver.Manage().Cookies.DeleteAllCookies(); break; //Back Click case ActGenElement.eGenElementAction.Back: //TODO: FIXME: This action should not be part of GenElement PressBackBtn(); break; case ActGenElement.eGenElementAction.CloseBrowser: Dictionary <String, Object> pars = new Dictionary <String, Object>(); Driver.ExecuteScript("mobile:monitor:stop", pars); break; } }
public void RightClick_Test() { ActGenElement act = new ActGenElement(); //act.LocateBy = eLocateBy.ByName; //act.GenElementAction = ActGenElement.eGenElementAction.Hover; //act.LocateValueCalculated = "lastName"; //act.Active = true; //mBF.CurrentActivity.Acts.Add(act); //mBF.CurrentActivity.Acts.CurrentItem = act; //mGR.RunAction(act, false); act = new ActGenElement(); act.LocateBy = eLocateBy.ByName; act.GenElementAction = ActGenElement.eGenElementAction.SetValue; act.LocateValueCalculated = "lastName"; act.Value = "CoreTeam"; act.Active = true; mBF.CurrentActivity.Acts.Add(act); mBF.CurrentActivity.Acts.CurrentItem = act; mGR.RunAction(act, false); act = new ActGenElement(); act.LocateBy = eLocateBy.ByName; act.GenElementAction = ActGenElement.eGenElementAction.SetValue; act.LocateValueCalculated = "lastName"; act.Value = "*****@*****.**"; act.Active = true; mBF.CurrentActivity.Acts.Add(act); mBF.CurrentActivity.Acts.CurrentItem = act; mGR.RunAction(act, false); act = new ActGenElement(); act.LocateBy = eLocateBy.ByName; act.GenElementAction = ActGenElement.eGenElementAction.RightClick; act.LocateValueCalculated = "lastName"; act.Active = true; mBF.CurrentActivity.Acts.Add(act); mBF.CurrentActivity.Acts.CurrentItem = act; mGR.RunAction(act, false); act = new ActGenElement(); act.LocateBy = eLocateBy.ByXPath; act.GenElementAction = ActGenElement.eGenElementAction.SendKeys; act.LocateValueCalculated = "/html[1]/body[1]/div[1]/table[1]/tbody[1]/tr[2]/td[2]/table[1]/tbody[1]/tr[2]/td[1]/table[1]/tbody[1]/tr[1]/td[3]/div[1]/form[1]/table[1]/tbody[1]/tr[3]/td[1]/table[1]/tbody[1]/tr[2]/td[1]/table[1]/tbody[1]/tr[2]/td[2]/table[1]/tbody[1]/tr[1]/td[1]/table[1]/tbody[1]/tr[3]/td[3]/input[1]"; act.Value = "u"; act.Wait = 2; act.Active = true; mBF.CurrentActivity.Acts.Add(act); mBF.CurrentActivity.Acts.CurrentItem = act; mGR.RunAction(act, false); act = new ActGenElement(); act.LocateBy = eLocateBy.ByName; act.GenElementAction = ActGenElement.eGenElementAction.GetValue; act.LocateValueCalculated = "lastName"; act.AddNewReturnParams = true; act.Active = true; mBF.CurrentActivity.Acts.Add(act); mBF.CurrentActivity.Acts.CurrentItem = act; mGR.RunAction(act, false); Assert.AreEqual(act.Status, eRunStatus.Passed, "Action Status"); string actual = act.GetReturnParam("Actual"); Assert.AreEqual(actual, "CoreTeam", "True"); Assert.AreEqual(act.Error, null, "Act.Error"); }