0

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'
4
  • Are you running locally or in a container? Commented May 30, 2020 at 12:05
  • I run it locally now Commented May 30, 2020 at 12:16
  • Are you getting locally the same error? Commented May 30, 2020 at 12:17
  • Yeah, I am running this code from my local machine and get this error. I am trying to find a way to increase the TimeOut in the right way Commented May 30, 2020 at 12:32

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

3 Comments

It worked! Thank you! Could you advice please, why you asked where I run it? What will be the difference? Or if it is a long topic, maybe you can tell me what I need to learn? Thanks :)
It is a short one. The error that you see is consistent with a "false" error when running in containers. If a container does not have big enough shm (shared memory space) it will throw the same error, misleading people into fixing problem that does not exist.
Thank you for your explanation! Will note it for the future

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.