当它是快乐路径时,如何解决readtimeout?

时间:2017-03-21 20:32:15

标签: ruby selenium capybara

没有模态或警告弹出窗口。按下按钮会将我带到一个页面,使得selenium无法再看到控件。

我已经厌倦了重新获取页面但没有成功。

visit([purchase page])
login
sleep(10)
find(:xpath, './/div[@class="tab-pane active"]/div/div/button[@class="btn btn-primary"]').click

Net::ReadTimeout (Net::ReadTimeout)

我相当确定的是,我没有找到我的元素,因为我没有生成

ElementNotFound

我的问题是,我想尝试获取selenium以查看我希望操作的页面有哪些工具?

1 个答案:

答案 0 :(得分:0)

我调试此方法的一种方法是在xpath之前和之后放置save_and_open_page。我的猜测是它无法找到点击的xpath和它的超时。

page.driver.browser.switch_to.window(page.driver.browser.window_handles.last)
page.driver.browser.switch_to.window(page.driver.browser.window_handles.first)
save_and_open_page 
find(:xpath, './/div[@class="blah active"]/div/div/button[@class="btn btn-primary"]').click
save_and_open_page 

如果不是这种情况,您可以尝试将超时设置为90秒以查看是否有帮助。

# https://github.com/teamcapybara/capybara/issues/1305
Capybara.register_driver :selenium do |app|
  profile = Selenium::WebDriver::Firefox::Profile.new
  client = Selenium::WebDriver::Remote::Http::Default.new
  client.timeout = 90 # instead of the default 60
  Capybara::Selenium::Driver.new(app, browser: :firefox, profile: profile, http_client: client)
end

基于您的Firefox错误

  1. 访问https://ftp.mozilla.org/pub/utilities/profilemanager/1.0/
  2. 下载profilemanager.mac.dmg
  3. 打开个人资料管理器
  4. 选择默认值或创建新的个人资料管理器
  5. 点击启动firefox
  6. 现在应该修复错误
相关问题