等待对id的响应超时,名称:"访问"," args

时间:2018-01-31 09:12:15

标签: ruby-on-rails ruby

首先,我知道有关同一问题的问题存在多个问题。但是,我似乎无法用这些问题的建议答案解决这个问题。我试过了:

  • expect(page).to have_content
  • Capybara.reset_sessions!
  • page.driver.reset!
  • 增加睡眠时间
  • 更新了所有宝石

这些解决方案似乎都没有效果。前几次运行这些钩子无头运行它运行正常,这是第三次这些TimeOuts启动。我还可以尝试其他选择吗?

  

等待响应{" id":" 9b2de783-a6bc-4fc6-a0a2-1a0e17ead8b2"," name":"访问& #34;" ARGS":[" http://test.com/login",30]}。这可能是因为某些事情需要很长时间(例如页面加载速度很慢)。如果是这样,将Poltergeist:timeout选项设置为更高的值将有所帮助(有关详细信息,请参阅文档)。如果增加超时没有帮助,这可能是Poltergeist中的一个错误 - 请将其报告给问题跟踪器。 (水豚::吵闹鬼:: TimeoutError)   ./features/support/hooks.rb:10:in在之前'

钩子代码:

$portal = 'http://test.com'

Before do |scenario|
  if Capybara.javascript_driver == :selenium
    page.driver.browser.manage.window.maximize
    end
end

Before('@portal_page_is_open') do
  visit "#{$portal}/login"
  expect(page).to have_content("Log in")
end

Before('@superuser_is_logged_in') do
  fill_in '_username', :with => 'testsuperuser'
  fill_in '_password', :with => 'Test1234'
    click_on 'Log in'
  sleep(5)
end

Before('@player_is_found') do
  expect(page).to have_content("Hi testsuperuser")
  advanced_search = find('#playerSearch > div > div.pull-right > button.advanced-search.btn.btn-link.btn-small')
  advanced_search.click
  sleep(5)
  fill_in 'playerSearch[customerSearch][firstName]', :with => $first_name
  fill_in 'playerSearch[customerSearch][surname]', :with => $last_name
  fill_in 'playerSearch[customerSearch][dateOfBirth]', :with => $date_of_birth
  sleep(1)
  click_on 'Search'
  until page.has_no_content?('Processing request...')
    sleep(5)
  end
end

After do |scenario|
  Cucumber.wants_to_quit = true if scenario.failed?
  Capybara.current_driver = Capybara.default_driver
  Capybara.reset_sessions!
  sleep(10)
end

超时设置:

   Capybara.register_driver :poltergeist do |app|
      Capybara::Poltergeist::Driver.new(app, {debug: false})
      Capybara::Poltergeist::Driver.new(app, timeout: 120)
      Capybara::Poltergeist::Driver.new(app, {js_errors: false})
 end 

宝石清单:

ruby "2.3.3"
gem "rdoc", "6.0.1"
gem "rspec", "3.7.0"
gem "capybara", "2.17.0"
gem "cucumber", "3.1.0"
gem "selenium-webdriver", "3.8.0"
gem "chronic", "0.10.2"
gem "poltergeist", "1.17.0"
gem "pg", "1.0.0"
gem "rest-client", "2.0.0"
gem "stomp", "1.4.4"
gem "net-ssh", "3.2.0"
gem "net-scp", "1.2.1"
gem "savon", "2.11.1"
gem "json"
gem "rake"

1 个答案:

答案 0 :(得分:0)

问题是在运行测试无头时发生的JSphantom错误弹出。

向After hook添加:page.driver.restart if defined?(page.driver.restart)解决了这个问题。