0

I wrote a console application (visual studio 2013, C#) to test my web site with selenium.

This is my code

    public static void Main(string[] args)
    {
        IWebDriver driver = new FirefoxDriver();
        driver.Navigate().GoToUrl("myUrl");

        WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(40));
        wait.Until(ExpectedConditions.ElementExists(By.Id("wsConnected")));

        driver.Quit();
    }

wsConnected is a div I put in page with jquery after page load (less than 10 seconds).

I am using Selenium 2.46.0 with Firefox v39.0

Of course it doesn't work because I get the driver timeout error after 60 seconds, any help will be very appreciated.

Thanks, Alessandro

[UPDATE] wait.Until fails with this exception: An unhandled exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.Support.dll. Additional information: The HTTP request to the remote WebDriver server for URL http://localhost:7056/hub/session/86847fde-462b-47be-85e1-31cd51791dc3/element timed out after 60 seconds.

[UPDATE 2] I downgraded Selenium to 2.43 and firefox to v32, no timeout, endless wait

6
  • So, wsConnected is not present in you page when it loads? and It is explicitly inserted once page loads, right? Commented Jul 10, 2015 at 9:09
  • Yes, thats the code in load $('body').append('<div id="wsConnected"></div>'); Commented Jul 10, 2015 at 9:36
  • Can you try adding a short sleep after navigating to the URL, may be of 10 seconds (assuming 10 seconds to be max time taken to insert the div), see if this works, later you/we can work on optimizing the same. Commented Jul 10, 2015 at 9:45
  • I have the same timeout error Commented Jul 10, 2015 at 9:52
  • Timeout of 60 seconds, but your wait is a timeout of 40? Do you mean it fails with this error before it even gets to the wait? Commented Jul 10, 2015 at 10:47

1 Answer 1

0

Try to avoid using of ExpectedConditions.
Cause of error will be much more clear.
The next code was tested with the latest version of selenium (Selenium Support Classes 2.48.2 and WebDriver 2.48.2 from nuget packages). It works fine even if element become visible in 10 seconds.

IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("https://www.google.ru/");
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(40));
wait.Until(d => d.FindElement(By.Id("logocont")));
driver.Quit();

If it does not help, please provide an inner exception of the timeout exception.

Sign up to request clarification or add additional context in comments.

1 Comment

WebDriverWait is buried into OpenQA.Selenium.Support.UI.WebDriverWait . Didn't work for me but thanks anyway.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.