Problems with Webdriver get method when URL is frozen

4,839 views
Skip to first unread message

cesar1983

unread,
Feb 21, 2011, 8:02:25 AM2/21/11
to webdriver
Hello.

I need some help here. I have automated some tests here in the company
I work for. My switchs are triggered by an Hudson Job. So I execute my
automated tests everyday with Hudson.

My problem is when the URL I am trying to get with my WebDriver object
is frozen for some reason. If it has very slow response. The browser
opens but I get nothing from it and the execution stops forever.

So the program stops in the Webdriver object get exection forever,
untill someone see that it stoped and close it by hand.

I need to treat that someway... anyone has done that?

Thanks

cubetree-qa

unread,
Feb 22, 2011, 3:38:59 AM2/22/11
to webdriver
Hi, I have exact same problem. sometimes my junit test get stuck at
driver.get("some url") method and it doesn't return unless i manually
go and stop the test.

don't know how to reproduce it but after reading your post, i would
try to simulate what you had said. i.e: try to put some delay in the
url and see whether the driver.get() would time out or not.

Thanks!

cubetree-qa

unread,
Feb 22, 2011, 3:47:35 AM2/22/11
to webdriver
In my case I'm using Remote webdriver, firefox 3.x brwoser for the
tests. webdriver version beta 2.0.b1

there are no 3rd party urls (like Ads) involved on the application.
everything is fromone host.

cesar1983

unread,
Feb 22, 2011, 7:49:46 AM2/22/11
to webdriver
Hi, well I have tried the timeouts, but they don´t work for that...

I am using 2.0.b2 and firefox 3.6.13 ... but the problem is not
related to the browser, as it happens with IE as well...

I just need to have some kind of control over the get method... There
must to be some timeout or some way to control it

Bill Ross

unread,
Feb 22, 2011, 1:12:31 PM2/22/11
to webd...@googlegroups.com
> So the program stops in the Webdriver object get exection forever,
> untill someone see that it stoped and close it by hand.
>
> I need to treat that someway... anyone has done that?

You could always start another thread to watch the one that hangs
and clean up if it times out.

Bill

cesar1983

unread,
Feb 24, 2011, 11:53:35 AM2/24/11
to webdriver
Well... I wanted something cleaner to solve this problem...

As there is no other way, I did it, I have now a thread to control
it.. i give it 5 seconds, if it do not open, i just finish the
operation and close the browser...

Thanks for the help

darrell

unread,
Feb 25, 2011, 10:25:10 AM2/25/11
to webdriver
As a Java programmer, I'm curious if the @Test annotation timeout
would act any differently than setting a WebDriver timeout. You could
have your code such that all tests are:

@Test(timeout=5000)
public void whateverYouWantToTestGoesHere() {
// test code here
}

then have an @After method to kill the browser if it doesn't close
down properly.

ElaNte

unread,
Mar 12, 2011, 8:27:38 AM3/12/11
to webdriver
Hello Bill,

because this issue drive crazy also me for long time, can you please
give meany tip how you manage to do that in Java?

I am using WebDriver with FF on OS X and i run several test in
parallel with the executor but i cant find any way to kill the threads
that are taking too much time to finish.

Thank you in advance!
Dimitris

Bill Ross

unread,
Mar 13, 2011, 4:00:41 AM3/13/11
to webd...@googlegroups.com
Hi Dimitris,

I don't think you can necessarily kill such threads - you may just
need to bypass them, with the watcher thread declaring the test a
failure. Hopefully the lost threads are not using cpu. It would be
worth having the watcher wait while you check cpu to see if the 'dead'
thread is active, then if you are lucky and there is no cpu, just
continue testing. If not, decide whether the cpu impact is worth
ending the JVM over.

Bill

cubetree-qa

unread,
Mar 13, 2011, 5:44:29 AM3/13/11
to webdriver
Bill,

Not sure if you experienced this problem yourself. What we really need
here is a clean way of killing that runaway thread so that it won't
put consume resources, and then then we need to re-run the same test.
Do you have a clean way of killing that thread and re-run the test in
junit? killing JVM is not an option as it would make your test system
unreliable.

Thanks!

ElaNte

unread,
Mar 13, 2011, 10:50:50 AM3/13/11
to webdriver
Will be great if there was an ConnectionTimeout exception everytime we
try to get a URL.

I saw alot of people to have this problem but still no any solution!

Simon in issue 687:
http://code.google.com/p/selenium/issues/detail?id=687&can=1&q=timeout%20page%20load&colspec=ID%20Stars%20Type%20Status%20Priority%20Milestone%20Owner%20Summary

said that this is a firefox issue but i couldn't find any config to do
it, since the old conection:timeout congiguration doeasn;t exist
anymore in FF.

Any tip will be much appreciate!

Dimitris

Bill Ross

unread,
Mar 13, 2011, 4:02:20 PM3/13/11
to webd...@googlegroups.com
Dimitris,

I have not experienced this problem. I wonder if a thread could register
to take interrupts. If there's no way to do this or kill the thread
outright, then the monitoring thread could write test status to a
checkpoint file and exit with status that would cause the invoking
shell script to relaunch using the checkpoint file, which could e.g.
have a bunch of serialized java classes. Then test execution would be
relatively seamless across the break.

ElaNte

unread,
Mar 21, 2011, 11:08:37 AM3/21/11
to webdriver
Hello guys,

i spend this weekend with this problem and below is the two things
that i tried but with no any success:

1. First i tried to run the get function as a thread and use the join
function with a time out in order to be sute that will take too much
time to finish:

WebDriver driver = new FirefoxDriver();
String url = "http://www.google.com";
//The TestGet class is just a Runnable which executes:
this.driver.get(url);
TestGet task = new TestGet(driver,url);
Thread t = new Thread(task, "Timeout guard");
t.setDaemon(true);
t.start();

try {
TimeoutController.execute(t, 2000ms);
} catch (TimeoutException e) {
System.out.println("Thread interrupted:");
driver.close();
}

//TimeoutController.execute is simply a join to the given Thread:
public static void execute(Thread task, long timeout) throws
TimeoutException {
try {
task.join(timeout);
} catch (InterruptedException e) { }
if (task.isAlive()) {
task.interrupt();
throw new TimeoutException();
}
}

Now this Throws an exception:
Invalid use of SingleClientConnManager: connection still allocated.

Which probably is because WebDriver is not thread safe...please
correct me if am i wrong..

2. The second thing that i tried was to execute the window.stop()
method before i will run the get() method with the WebDriver:

WebDriver d = new FirefoxDriver();
executJavaScript("var loadTimeout=setTimeout(\"window.stop();\",
timeOut);",d);
d.get("http://www.google.com");
d.quit();

But no again. Should stop loading after the timeout but only works
when i put a very small timeout. This is probably because :

"Because of the order in which scripts are loaded, the stop() method
cannot stop the document in which it is contained from loading, but it
will stop the loading of large images, new windows, and other objects
whose loading is deferred."[1]

I suppose the best solution is to implement the get() timeout on our
selfs but i really dont know from where to start since i am newbie on
Http things...

Best,
Dimitris


[1]https://developer.mozilla.org/en/DOM/window.stop

Yoel Krupnik

unread,
Feb 21, 2014, 12:52:43 PM2/21/14
to webd...@googlegroups.com, dimitris...@gmail.com
Hi Guys,

So is there any solution here?

webdriver.get(some_url) is stuck while using python+firefox on Kubuntu.

Thanks,
Joel

darrell

unread,
Feb 23, 2014, 9:18:35 AM2/23/14
to webd...@googlegroups.com, dimitris...@gmail.com
Joel,

This thread is 3 years old. Whatever the initial problem is I would expect updating from a BETA version of WebDriver has solved it. Or whatever the initial problem is was solved so long ago that the people involved don't even remember it.

If you are having a similar problem today then I would recommend you post a new thread with the relevant information and not associate yourself with a 3 year old thread.

Which version of WebDriver are you using? Which version of python? Version of Firefox? Produce a minimal example that you can post. Essentially, more details.
Reply all
Reply to author
Forward
0 new messages