Follow the below part of the code:
driver.get "https://example.com/" element = driver.find_element :name => "username" element.send_keys "*****" element = driver.find_element :name => "password" element.send_keys "*****" element.submit
Now point is when the driver
opened the URL on the browser, Some times the next page to which username and password has to be put by the script, not coming- which causes the script to failed. Some intermediate page is coming asking us to click on 'retry button' or 'refresh the page'. Thus the script whenever such case occurred stopped execution, as not getting the mentioned element.
So is there any way to refresh that intermediate page with "sleep" before going to the "Log-in" page, so that script can run in one go?
Create a webdriver (here chromedriver for chrome browser). Build a new window of chrome using the chromedriver. Navigate to geeksforgeeks website using the get method. Refresh the page using refresh method.
The refresh() method is used to refresh the currrent page in selenium.
Refresh () - Selenium IDE command Refresh reloads the currently loaded page.
For Capybara, I think Tommyixi's comment is the best:
visit current_path
As mentioned in a comment by @Nakilon, with non-Poltergeist drivers in Capybara use the following to refresh the current page:
page.driver.browser.navigate.refresh
But for a universal fix, use:
page.evaluate_script 'window.location.reload()'
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