【发布时间】:2020-09-17 22:46:02
【问题描述】:
使用 Selenium + Ruby 构建我的第一个测试。有一个步骤我必须登录。 我正在传递登录名和密码,然后脚本单击“登录”按钮。
登录过程可能需要一段时间(系统细节 - 一直都是这样,没关系)。因此,当我的脚本等待登录时,大约 100 秒后,我的代码会出现错误:
/usr/local/Cellar/ruby@2.5/2.5.8/lib/ruby/2.5.0/net/protocol.rb:181:in `rbuf_fill': Net::ReadTimeout (Net::ReadTimeout)
我假设我需要设置类似 timeout 的时间,例如最长 240 秒,但找不到正确的方法。
您能帮我设置一个正确的超时属性吗?
谢谢!
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'
【问题讨论】:
-
你是在本地运行还是在容器中运行?
-
我现在在本地运行
-
你在本地遇到同样的错误吗?
-
是的,我正在本地机器上运行此代码并收到此错误。我正在尝试找到一种以正确方式增加 TimeOut 的方法
标签: ruby selenium selenium-webdriver