If how to use wait_until is pretty clear (I've used the methods like this while creating tests through the native Webdriver methods), but not the new synchronize method (sorry:)). I've read the theme about why wait_until is deprecated, I've read the article about that, I've read the docs with method description and also read the code where the description present too. But I didn't find any example or tutorial how exactly to use this method.
Anybody, please, provide few cases where I (and maybe someone else) could see and learn how to use this method
For example the case
expect(actual).to equal(expected)
where should I "put" synchronize method to get negative exception only after timeout had been passed?
UPD: For those who interested please look into this links:
http://www.elabs.se/blog/53-why-wait_until-was-removed-from-capybara
https://github.com/jnicklas/capybara/blob/master/lib/capybara/node/base.rb#L44
I just found a case where I needed to use #synchronize. I have a helper method which looks for an element on the page and if it exists it clicks on it and returns some text that gets updated on the page (via JavaScript). There are cases where between finding the element and clicking on it, it might disappear (and possibly re-appear) due to other JavaScript code and could raise a Selenium::WebDriver::Error::StaleElementReferenceError exception. So I use synchronize like this:
page.document.synchronize do
element = first('#whatever')
if element
element.click
find('#foo').text
else
nil
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With