Capybara - spec with `inside_window` does not work without` sleep`
source link: https://www.codesd.com/item/capybara-spec-with-inside-window-does-not-work-without-sleep.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Capybara - spec with `inside_window` does not work without` sleep`
I have a spec that clicks a button, which triggers some JS generating url and opens it in a new window:
new_window = window_opened_by { find('#search_postcode').click }
within_window new_window do
expect(page.current_url).to include('postcode.nl')
end
This does not work. I get the following error:
Failure/Error: expect(page.current_url).to include('postcode.nl')
expected "about:blank" to include "postcode.nl"
However, when I add sleep 1
, the spec passes:
within_window new_window do
sleep 1
expect(page.current_url).to include('postcode.nl')
end
Is it possible to get this working without the sleep
?
You can check for a selector within the new windows html. Capybara then should wait the default_waittime for the element to appear. Like:
within_window new_window do
expect(page).to have_selector('.your_class_here')
expect(page.current_url).to include('postcode.nl')
end
Related Articles
Sync problem with Jquery - does not work without warning
Logging in with MSBuild does not work with files extracted in BATCH
Flash does not work without www
Android paddingBottom does not work without paddingTop
The website does not work without default.aspx
My project codeigniter does not work without index.php online
Codeigniter does not work without index.php in Get Requests?
spark-submit yarn-cluster with --jars does not work?
Jquery. Changing the width of div with animation does not work
Xpath to locate li with text does not work
Rails 3 best_in_place edit does not work without refreshing the page
Application with XDK does not work
Using the lein project with / lib does not work
The Python Spark Streaming example with textFileStream does not work. Why?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK