public void scrollToElement(byFields by, string element) { log("scrollToElement"); IWebElement elem = driver.FindElement(getBy(by, element)); ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", element); }
public bool isElementPresent(byFields by, string element) { log("isElementPresent(" + by + "," + element + ")"); try { driver.FindElement(getBy(by, element)); log("isElementPresent return: true"); return(true); } catch (Exception) { log("isElementPresent return: false"); return(false); } }
public void setDropDownText(byFields by, string element, string text, int timeOut) { log("setDropDownText(" + by + ", " + element + "," + text + ")"); try { waitForElement(timeOut, getBy(by, element)); new SelectElement(driver.FindElement(getBy(by, element))).SelectByText(text); } catch (Exception ex) { log("setdropdowntext error" + ex.ToString()); methodError(ex); } takeScreenStep("setDropDownText"); }
public void submitElement(byFields by, string element, int timeOut) { log("submitElement(" + by + ", " + element + ")"); try { waitForElement(timeOut, getBy(by, element)); driver.FindElement(getBy(by, element)).Submit(); } catch (Exception ex) { log("submitelement error" + ex.ToString()); methodError(ex); } takeScreenStep("submitElement"); }
public string getValue(byFields by, string element, int timeOut) { log("getValue(" + by + ", " + element + ")"); try { waitForElement(timeOut, getBy(by, element)); driver.FindElement(getBy(by, element)).GetAttribute("value"); } catch (Exception ex) { log("getvalue error" + ex.ToString()); methodError(ex); } return(driver.FindElement(getBy(by, element)).GetAttribute("value")); }
public string getText(byFields by, string element, int timeOut) { log("getText(" + by + ", " + element + ")"); try { waitForElement(timeOut, getBy(by, element)); driver.FindElement(getBy(by, element)).Text.ToString(); } catch (Exception ex) { log("gettext error" + ex.ToString()); methodError(ex); } return(driver.FindElement(getBy(by, element)).Text); }
public void clickElement(byFields by, string element, int timeOut) { log("clickElement(" + by + ", " + element + ")"); try { waitForElement(timeOut, getBy(by, element)); driver.FindElement(getBy(by, element)).Click(); waitOnPageLoad(); } catch (Exception ex) { log("clickelement error" + ex.ToString()); methodError(ex); } takeScreenStep("clickElement"); }
public void sendText(byFields by, string element, string data, int timeOut, bool clear = false) { log("sendText(" + by + ", " + element + ", " + data + ", " + clear + ")"); try { waitForElement(timeOut, getBy(by, element)); if (clear) { clearText(by, element, timeOut); } driver.FindElement(getBy(by, element)).Click(); driver.FindElement(getBy(by, element)).SendKeys(data); } catch (Exception ex) { log("sendtext error" + ex.ToString()); methodError(ex); } takeScreenStep("sendText"); }
public By getBy(byFields by, String element) { if (by == byFields.id) { return(By.Id(element)); } else if (by == byFields.name) { return(By.Name(element)); } else if (by == byFields.css) { return(By.CssSelector(element)); } else if (by == byFields.tag) { return(By.TagName(element)); } else if (by == byFields.className) { return(By.ClassName(element)); } else if (by == byFields.linkText) { return(By.LinkText(element)); } else if (by == byFields.partialLinkText) { return(By.PartialLinkText(element)); } else if (by == byFields.xpath) { return(By.XPath(element)); } else { return(By.Id("")); } }