在 heroku 上使用 selenium webdrivers 时出现以下错误。 (rspec-> capybara -> Selenium )
Net::ReadTimeout: Net::ReadTimeout with #<TCPSocket:(closed)>
heroku-buildpack-google-chrome
buildpack,带有 webdrivers-gem。chrome_shim = ENV.fetch("GOOGLE_CHROME_SHIM", nil)
Selenium::WebDriver::Chrome.path = chrome_shim
chrome_opts = { "chromeOptions" => { "binary" => chrome_shim } }
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(chrome_opts)
)
end
Capybara.javascript_driver = :headless_chrome
Webdrivers.logger.level = :DEBUG
输出在这里 https://gist.github.com/IanVaughan/3e0c50d2fa4a60e672b96f6726fbbb8ccapybara (3.30.0)
webdrivers (4.2.0)
selenium-webdriver (3.142.7)
RSpec.feature 'User signup flow', :js do
scenario 'Visits home page to signup' do
visit root_path
new_window = window_opened_by { click_link 'Sign Up', match: :first }
within_window new_window do
expect(page).to have_text('New Enquiry', wait: 5)
end
end
最佳答案
如果超时发生在您的应用程序第一次请求期间,而应用程序则一次性执行某些操作(编译 Assets 等),那么您可能需要增加允许的读取超时
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(
...
timeout: 60 # defaults to 30 IIRC
)
end
关于selenium-webdriver - 在 Heroku 上使用 webdrivers selenium 获取 ReadTimeout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59723188/
相关文章:
visual-studio-2015 - IApplicationBuilder 不包含 UseWe
proxy - JProfiler - 有防火墙时如何配置远程应用程序?
visual-studio-code - 如何在 visual studio 代码中显示完整的长行(
azure - 使用 Azure SQL 的 ASP.Net Core 2.1 Serilog SQ
scala - 如何使用 Scala 在 lagom 中为 NoHostAvailableExcep
macos - undefined symbol : "boost::system::generic