Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
def create_button
@driver.find_element(:link, 'Create')
def create_button_click
@wait = 8)
puts 'DEBUG: Clicking Create Button'
puts 'DEBUG: Waiting for View This Challenge'
@wait.until { @driver.find_element(:link, 'view this challenge') }
puts 'DEBUG: Found view challenge link'
puts 'DEBUG: Rescue: Clicking Create Button'
@wait.until { @driver.find_element(:link, 'view this challenge') }
puts 'DEBUG: Found view challenge link'
Copy link

tourdedave commented Sep 16, 2014

The problem (as I understand it):

The wait doesn't observe 8 seconds. Instead, it waits for 60 seconds.

Here are my thoughts/questions on this:

  1. Is the @wait shown here the only one in your test code? (e.g., is the wait getting overwritten by a same named instance variable somewhere else in your test code?)
  2. What is the error message you are seeing? If it's 60 seconds, then it's likely the Net::HTTP timeout, which means that the exception from the explicit wait isn't being observed
  3. What is the purpose of the rescue statement? You're just repeating the same actions over again, which shouldn't be necessary with an explicit wait. This has the highest probability of causing the behavior you're seeing. You're rescuing without specifying an exception, so anything will get rescued, including a timeout exception from an explicit wait. I would remove this and test to see what happens.


Copy link

jimmyeisenhauer commented Sep 16, 2014

Yeah there is something weird going on with my waits. I had the same problem with wait not set as a instance var as well. I moved to a instance var to aid in some trouble shooting.

The implicit wait i moved to 30 seconds and I still see the explicit one at 60 seconds, which is prob http like you stated.
@driver.manage.timeouts.implicit_wait = 30

I added
client =
client.timeout = 120 # seconds

as a work around it just takes a while :-)

The rescue is there to attempt the click again if the first one fails.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment