Selenium WebdriverTimeoutException although the page is already loaded

199 Views Asked by At

I'm new to Selenium and try to automatically open a website in Full Screen mode.

  • The website has a Login which is already working with Selenium.
  • After the login only one button has to be pressed.

Hereby an WebdriverTimoutException is thrown in the second last line.

  • The InnerException says NoSuchElementException.
  • But when I open the web console, I can see the button.
IWebDriver driver = new EdgeDriver(System.IO.Directory.GetParent(System.IO.Directory.GetParent(Environment.CurrentDirectory).ToString()).ToString() + "\\webdriver");

driver.Navigate().GoToUrl(@"http://examplehomepage.com");

driver.FindElement(By.Id("username")).SendKeys("abc");
driver.FindElement(By.Id("password")).SendKeys("password123");
driver.FindElement(By.TagName("button")).Click();

driver.Manage().Window.FullScreen();

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));

IWebElement element = wait.Until(ExpectedConditions.ElementToBeClickable(By.TagName("button")));

element.Click();

I tried it with:

  • Edge (85.0.564.44)
  • Chrome (85.0.4183.83)
  • Firefox(80.0.1).
1

There are 1 best solutions below

1
Rahul On
  1. You can use sleep to delay the interaction
  2. You are using ElementToBeClickable. You should also use ElementToBeVisible and also check whether element is enabled as well from isEnabled function.