I've been playing with Capybara and the selenium web-driver to learn about web-automation. I've been trying to refresh a particular page with Capybara. I've seen a few methods but they each have issues that make them not feasible in certain cases.
session.visit link is just doing nothing, as the session is already at that link. I can do session.reset! but then I lose the login.
The few other methods I've seen - don't use Capybara's inbuilt wait functionality. This means if there is heavy server load - or in my tests with a restricted DL/UL rate the 'refresh' happens but then it quickly tries to look for a field in the next page that doesn't exist yet because it hasn't loaded.
So my question is specifically - how do I refresh a page in Capybara without loosing the login session using Capybara's inbuilt wait functionality?
you can do something like:
visit current_path
or define an RSpec helper:
def reload_page
visit current_path
end
Since you're using selenium, you can either use the master branch of Capybara and call
session.refresh
or you can stick with the current release version and call
session.driver.browser.navigate.refresh
If the page you're trying to refresh was a POST it may pop up an "are you sure you want to resbumit" modal, in which case you'd need something like
session.accept_confirm do
session.driver.browser.navigate.refresh
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