Home > OS >  Selenium Webdriver using isDisplayed() not working
Selenium Webdriver using isDisplayed() not working

Time:11-15

Goal: checking if the element exists on the page, if so, continue with the test, if it doesn't show an error and stop the test.

Boolean Display = Driver.FindElement(By.CssSelector(".mat - select")).isDisplayed();

Error CS1061 'IWebElement' does not contain a definition for 'isDisplayed' and no accessible extension method 'isDisplayed' accepting a first argument of type 'IWebElement' could be found (are you missing a using directive or an assembly reference?)

Boolean Display = Driver.FindElement(By.CssSelector(".mat - select")).Displayed();

Error CS1955 Non-invocable member 'IWebElement.Displayed' cannot be used like a method.

I will be grateful for your help!

CodePudding user response:

In C# Selenium there is no isDisplayed() method. Also Displayed is a property, not a method.
So instead of

Boolean Display = Driver.FindElement(By.CssSelector(".mat - select")).isDisplayed();

Try using

Boolean Display = Driver.FindElement(By.CssSelector(".mat - select")).Displayed;
  • Related