George
George

Reputation: 224

Catch timeout event in ruby selenium

Is there any way to catch all timeout error events in selenium , written in Ruby?

I am writing jenkins with selenium , but not sure the best way to terminate building tasks btw steps . The way I found so far is to put exec("exit 1") inside ruby file. However, I have no idea when to put this command . So , I'd like to catch all timeout error and trigger this event.

If there's any better way , please kindly advise ! Thanks!

Upvotes: 1

Views: 1056

Answers (1)

Arup Rakshit
Arup Rakshit

Reputation: 118271

Here is some hints to your problem:

begin

    wait = Selenium::WebDriver::Wait.new(:timeout => 10) # seconds
    wait.until { driver.title.include? "page title" }
    driver.find_element(:xpath, ".//*[@id='subTabHeaders']/div[3]")}.click

rescue Selenium::WebDriver::Error::TimeOutError

    exit(1)

end

Upvotes: 2

Related Questions