sarmisen / selenium-vba

Automatically exported from code.google.com/p/selenium-vba
0 stars 0 forks source link

set timeout for web page load for firefox? #107

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Operating system :
.Net Framework version :
Office Version :
SeleniumWrapper version :

What is your issue ?
I use "selenium.Open" to open a web page for firefox but the page is loading 
infinitely. How can set a timeout command for "selenium.Open" so that it can 
proceed to next command?  

Original issue reported on code.google.com by acco...@gmail.com on 11 Oct 2014 at 9:55

GoogleCodeExporter commented 9 years ago
To set the timeout and skip the exception when the timeout is reached:
 Dim wd as New SeleniumWrapper.WebDriver
 wd.start "firefox", "http://www..."
 wd.setTimeout 4000 'Sets a 4s  timeout
 On Error Resume Next
 wd.open "/"
 On Error Goto 0

Or you could block the urls responsible for the hanging with an url blocker 
like PeerBlock.

Original comment by florentbr on 11 Oct 2014 at 2:10

GoogleCodeExporter commented 9 years ago
The open command now integrates an optional timeout and raise option:
Dim wd as New SeleniumWrapper.WebDriver
wd.start "firefox", "http://www...
wd.open "/", 5000, false     'Sets a 5s timeout to load the page and returns 
false without throwing an error in case of timeout. Returns true if the page 
was successfully loaded.

Original comment by florentbr on 14 Oct 2014 at 5:36