On the ruby bindings page: (see driver examples)
# wait for a specific element to show up wait = Selenium::WebDriver::Wait.new(:timeout => 10)
So you can do something like:
wait = Selenium::WebDriver::Wait.new(:timeout => 40) wait.until do element = driver.find_element(:xpath, ".//*[@id='subTabHeaders']/div[3]") element.click end
Or more succinctly
wait = Selenium::WebDriver::Wait.new(:timeout => 40) wait.until { driver.find_element(:xpath, ".//*[@id='subTabHeaders']/div[3]").click }
However, since you say that clicking does not cause an error, it looks like clicking actually works, itβs just that your page is not really ready to display this tab. I assume there is asynchronous javascript here.
So, what you can try is inside the wait block, make sure that the click causes the desired change. I suppose, but you can try something like:
wait = Selenium::WebDriver::Wait.new(:timeout => 40) wait.until do driver.find_element(:xpath, ".//*[@id='subTabHeaders']/div[3]").click driver.find_element(:xpath, ".//*[@id='subTabHeaders']/div[3][@class='selected']") end
The important thing is that #until will wait and repeat until the block gets the true result or the timeout is exceeded.
source share