public static void ClickOnIt(this IWebElement element, string elementName) { if (elementName == null) { Report.Log(LogStatus.Fail, "Click", String.Format("[{0}] : clicked", elementName)); } else { element.Click(); WriteConsole.Cyan(String.Format("[{0}] : clicked", elementName)); Report.Log(LogStatus.Pass, "Click", String.Format("[{0}] : clicked", elementName)); } }
public static void SelectByValue(this IWebElement element, string elementName, string text) { if (elementName == null) { Report.Log(LogStatus.Fail, "Select Dropdown", String.Format("[{0}] : select [{1}]", elementName, text)); } else { SelectElement oSelect = new SelectElement(element); oSelect.SelectByValue(text); WriteConsole.Cyan(String.Format("[{0}] : select [{1}]", elementName, text)); Report.Log(LogStatus.Pass, "Select Dropdown", String.Format("[{0}] : select [{1}]", elementName, text)); } }
public static void EnterText(this IWebElement element, string elementName, string text) { if (elementName == null) { Report.Log(LogStatus.Fail, "EnterText", String.Format("[{0}] : key in [{1}]", elementName, text)); } else { element.Clear(); element.SendKeys(text); WriteConsole.Cyan(String.Format("[{0}] : key in [{1}]", elementName, text)); Report.Log(LogStatus.Pass, "EnterText", String.Format("[{0}] : key in [{1}]", elementName, text)); } }
public static void MouseOverThenClick(this IWebElement element, IWebDriver driver, string elementName) { if (elementName == null) { Report.Log(LogStatus.Fail, "MouseOverThenClick", String.Format("[{0}] : Hovered then click", elementName)); } else { Actions action = new Actions(driver); //Hover Element action.MoveToElement(element).Click().Perform(); //action.MoveToElement(element).Click().Perform(); //hover then click WriteConsole.Cyan(String.Format("[{0}] : Hovered then click", elementName)); Report.Log(LogStatus.Pass, "MouseOverThenClick", String.Format("[{0}] : Hovered then click", elementName)); } }
public static bool IsDisplayed(this IWebElement element, string elementName) { bool result; try { result = element.Displayed; WriteConsole.Cyan(String.Format("[{0}] : Displayed", elementName)); Report.Log(LogStatus.Pass, "IsDisplayed", String.Format("[{0}] : Displayed", elementName)); } catch (Exception) { result = false; WriteConsole.Cyan(String.Format("[{0}] : not Displayed", elementName)); Report.Log(LogStatus.Fail, "IsDisplayed", String.Format("[{0}] : not Displayed", elementName)); } return(result); }