3

I'm using Selenium Webdriver in Visual Studio 2015, with C#. The browser is IE (not because I want to, but becaue I have to). I'm organizing the tests in a Unit Test project, which calls Selenium in a Class Library project.

As of now, I'm having problems just opening the page I'm trying to test. The page opens, but the Selenium test keeps running until it times out in 2-3 minutes. It times out with this error:

Test failed - ...

Message: Test method Open_Page threw exception:
OpenQA.Selenium.WebdriverException: The HTTP request to the remote 
WebDriver server for URL http://localhost:20819/session/f6455....
/timeouts 
timed out after 60 seconds. --->
System.Net.WebException: The request was aborted: The operation has timed
out.
TestCleanup method ... threw exception.
OpenQA.Selenium.WebDriverException:
OpenQA.Selenium.WebDriverException: Unexpected error. Error 404: Not 
Found
Not Found.

This is my code (I believe the relevant parts, at least). I've simplified it and put the interesting Selenium code in unit test class.

[TestClass]
    public class OpenTests {

   ...
   ...
   ...
   public void Open_Opus_1 () {
        //StartPage.GoTo();

        IEDriver.Instance.Navigate().GoToUrl("https://REMOVED/");       


   }

   [TestCleanup] 
    public void Cleanup() {
        IEDriver.Close();
    }

The IEDriver class:

public class IEDriver {

    public static IWebDriver Instance { get; set; }

    public static void Initialize() {
        Instance = new InternetExplorerDriver();

    }

    public static void Close() {
        Instance.Close();
    }
}

I'm not sure what more information is relevant. What happening is that with this page, which is a very complicated page with lots of service polling and status displays of servers, services etc. etc., the page opens fine, but the test just keeps running until it times out with the above error(s).

If I replace the URL with (ex.) www.google.com, it works fine; the browser closes as the test passes.

So the problem is obviously this specific page. And since it just keeps running and timing out, I'm unable to do anything more. So I'm wondering if it's possible to force Selenium NOT to keep trying for whatever it tries or waits for, and say "the page is loaded now...moving on..."? Or something like that.

  • What is your test? opening the page timeouts? – Yahya Hussein Feb 8 '17 at 13:49
  • 1
    The test is just opening the page at this point, yes. The page opens, but Selenium keeps running and eventually times out. Most likely because of elements on the page. – Hfrav Feb 8 '17 at 13:56
  • I can not help you until you write your test code, generally this happens due to that selenium is searching for an element that is not there, you are saying that it takes 60 seconds, so I am guessing that a selenium wait is causing this. – Yahya Hussein Feb 8 '17 at 15:38
  • 1
    There IS no more test code than what I've included here. The only thing the code does is open the browser and go to the URL. That's it. I'm not trying to look for anything (yet). And it takes 2 or 3 minutes, varying from run to run. And if I change the URL to (ex) google.com, it works fine (that is, selenium opens the page and finishes). – Hfrav Feb 9 '17 at 9:35
  • 1
    I would be helpful to know or see the web site you're trying to open (or are opening). But I'm guessing maybe it's an internal or otherwise not publicly available site? – Frank H. Feb 9 '17 at 11:51
2

IE 10 had some issues and so did IE 11 at the start. The new IE driver has fixed some of those, but I'm not sure what version of things you are running. The work arounds include setting capabilities of the browser when starting it. Try the below settings and see if it works to help it stay focused on the newly opened window.

        capabilities = new DesiredCapabilities();
        capabilities.setCapability("ignoreProtectedModeSettings", true);
        capabilities.setCapability("ie.ensureCleanSession", true);
        webDriver = new InternetExplorerDriver(capabilities);

There are other possible, but based on your description I would think these would likely make it work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.