Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the page load Timeouts in Watir-Webdriver (timeout in .click method)

Tags:

I have the following code

browser.link(:text => 'Generate Report').click  
browser.radio(:value => 'byTotalValue').wait_until_present(180)  

which requests that a report be generated and then waits for the report by looking for an element on the report page. The report can take upwards of 2 minutes to appear.

What is happening is a Timeout::Error is being raised from the click method after 60 seconds. I suspect that Watir-Webdriver has implemented some form of wait for page load within the click method but I don't see a way to adjust the value.

Any help understanding this would be appreciated.

like image 942
user1142012 Avatar asked Jan 26 '12 04:01

user1142012


People also ask

How to set page load timeout in Selenium?

setScriptTimeout(5,TimeUnit. SECONDS); The pageLoadTimeout is the method used to set the time for the entire page load prior to throwing an exception. If the timeout time is set to negative, then the time taken to load the page is endless.

How to avoid timeout exception in Selenium WebDriver?

Solution. You can manually increase the wait time by hit-and-trial. If the problem persists for a longer period of time, there may be some other issue and you should continue onto the next solution. You can explicitly add wait by using JavaScript Executor.

What is the default page load timeout in selenium Webdriver?

By default, it is set to 0 (which equates to an infinite time out). If you want to ensure that an error is thrown if your page takes longer than expected to load, you can modify this by using this line of code: driver. manage().


1 Answers

I'd try upping the client timeout:

client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 180 # seconds – default is 60

b = Watir::Browser.new :firefox, :http_client => client
like image 104
Alister Scott Avatar answered Oct 11 '22 19:10

Alister Scott