Issue
Building my very first test with Selenium + Ruby. There is a step where I have to log in. I am passing login and password, then the script clicks "Log in" button.
The login process may take a while (system specifics - it's constantly like that and ok). So, while my script is waiting to log in, after ~100 seconds my code breaks into the error:
/usr/local/Cellar/[email protected]/2.5.8/lib/ruby/2.5.0/net/protocol.rb:181:in `rbuf_fill': Net::ReadTimeout (Net::ReadTimeout)
I assume I need to set up something like a timeout
timing up to 240 sec for example but can't find the right way of doing that.
Could you help me to set up a right timeout property, please?
Thank you!
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome
# driver.manage.timeouts.implicit_wait = 240 - Tried it, didn't help
# driver.manage.timeouts.page_load = 240 -
driver.navigate.to 'https://webiste.com'
#Entering my login and password
driver.find_element(id: 'admin_user_email').send_keys('MY_LOGIN')
driver.find_element(id: 'admin_user_password').send_keys('MY_PASSWORD')
#Clicking Login button and at this step my script breaks after ~100 sec
driver.find_element(id: 'admin_user_submit_action').click
driver.navigate.to 'https://another_URL_after_logged_in'
puts 'You are on the page'
Solution
As asked for in the comments. The timeout can be increased by doing this:
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 240 # Or whatever you need
driver = Selenium::WebDriver.for :chrome, :http_client => client
Answered By - Saša Zejnilović
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.