public static void ClearTextElement(AndroidDriver <AppiumWebElement> webDriver, string by, string elementName, int timeInSeconds) { switch (by) { case "id": webDriver.FindElementById(elementName).Clear(); break; case "xPath": webDriver.FindElementByXPath(elementName).Clear(); break; case "cssSelector": webDriver.FindElementByCssSelector(elementName).Clear(); break; case "name": webDriver.FindElementByName(elementName).Clear(); break; case "className": webDriver.FindElementByClassName(elementName).Clear(); break; } Thread.Sleep(timeInSeconds * 1000); }
public static string GetValueFromElement(AndroidDriver <AppiumWebElement> webDriver, string by, string elementName, int timeInseconds) { string elementText = ""; switch (by) { case "id": elementText = webDriver.FindElementById(elementName).GetAttribute("value"); break; case "xPath": elementText = webDriver.FindElementByXPath(elementName).GetAttribute("value"); break; case "cssSelector": elementText = webDriver.FindElementByCssSelector(elementName).GetAttribute("value"); break; case "name": elementText = webDriver.FindElementByName(elementName).GetAttribute("value"); break; case "className": elementText = webDriver.FindElementByClassName(elementName).GetAttribute("value"); break; case "linkText": elementText = webDriver.FindElementByLinkText(elementName).GetAttribute("value"); break; } Thread.Sleep(timeInseconds * 1000); return(elementText); }
public static void MoveToElement(AndroidDriver <AppiumWebElement> webDriver, string elementName, int timeInSeconds) { var element = webDriver.FindElementByCssSelector(elementName); Actions actions = new Actions(webDriver); actions.MoveToElement(element); actions.Perform(); Thread.Sleep(timeInSeconds * 1000); }
public void FirstTest() { _driver.Navigate().GoToUrl("https://www.khmerdev.com/"); //_driver.FindElementByCssSelector(".color-white > span"); if (_driver.GetType() == typeof(AndroidDriver <AndroidElement>)) { AndroidDriver <AndroidElement> androidDriver = (AndroidDriver <AndroidElement>)_driver; androidDriver.FindElementByCssSelector(".color-white > span"); } }