/// <summary> /// Verifies if an element is not enabled on the page. /// It uses WaitForElementUntilCondition /// </summary> /// <param name="element">the web element</param> /// <param name="elementName">the element name</param> /// <param name="page">the element page name</param> protected void IsElementNotEnabled(IWebElement element, String elementName, String page) { Assert.NotNull(element, "NPE::The element " + elementName + " on the page " + page + " is not populated."); try { Func <IWebDriver, Boolean> function = delegate(IWebDriver d) { return(element.Enabled == false); }; WaitsHandler.WaitForElementUntilCondition(DriverManager.GetDriver(), function, page); } catch (Exception) { Assert.Fail("The expected element " + elementName + "to be not enable IS enable on the page " + page); } }
/// <summary> /// Verifies if an element is not displayed on the page. /// It uses WaitForElementUntilCondition /// </summary> /// <param name="element">the web element</param> /// <param name="elementName">the element name</param> /// <param name="page">the element page name</param> protected void IsElementNotDisplayed(IWebElement element, String elementName, String page) { Assert.NotNull(element, "NPE::The element " + elementName + " on the page " + page + " is not populated."); try { if (element.TagName.Equals("i")) { Func <IWebDriver, Boolean> function = delegate(IWebDriver d) { return(element.GetAttribute("style").Equals("display: none;")); }; WaitsHandler.WaitForElementUntilCondition(DriverManager.GetDriver(), function, page); } else { Func <IWebDriver, Boolean> function = delegate(IWebDriver d) { return(element.Displayed == false); }; WaitsHandler.WaitForElementUntilCondition(DriverManager.GetDriver(), function, page); } } catch (Exception) { Assert.Fail("The expected element " + elementName + "to be not visible IS visible on the page " + page); } }
/// <summary> /// Verifies if an element is displayed on the page. /// It uses WaitForElementUntilCondition /// </summary> /// <param name="element">the web element</param> /// <param name="element">the display condition</param> /// <param name="elementName">the element name</param> /// <param name="page">the element page name</param> protected void IsElementDisplayed(IWebElement element, bool condition, String elementName, String page) { // Highlight(element); Assert.NotNull(element, "NPE::The element " + elementName + " on the page " + page + " is not populated."); try { Func <IWebDriver, Boolean> function = delegate(IWebDriver d) { return(element.Displayed == condition); }; WaitsHandler.WaitForElementUntilCondition(DriverManager.GetDriver(), function, page); } catch (Exception) { if (condition) { LogHandler.Error("IsElementDisplayed::The expected element " + elementName + "to be visible IS NOT visible on the page " + page); Assert.Fail("The expected element " + elementName + "to be visible IS NOT visible on the page " + page); } else { LogHandler.Error("IsElementDisplayed::The expected element " + elementName + "to be not visible IS visible on the page " + page); Assert.Fail("The expected element " + elementName + "to be not visible IS visible on the page " + page); } } }