60秒内无法获得稳定的firefox连接(127.0.0.1:7055)Selenium 3.6.0

时间:2018-12-05 12:48:34

标签: ruby selenium selenium-webdriver capybara selenium-firefoxdriver

我收到主题中提到的问题,这是一个间歇性问题。但是,它使我们的CI CD管道不稳定,因此可以从这个出色的平台上的极客那里获得一些帮助。

由于这是一个间歇性问题,因此我不希望升级我的浏览器版本,因为它主要是作为建议而提及它。

以下是一些详细信息,可以帮助您确定我无法找到的原因

我使用什么库-

gem 'selenium-webdriver', '3.6.0'
gem 'capybara', '2.18.0'
gem 'site_prism', '2.11'

我使用什么浏览器-

Firefox - 52.8.0

我使用哪个操作系统-

RHEL7

如何配置驱动程序-

 firefox_profile = Selenium::WebDriver::Firefox::Profile.new
  firefox_profile['browser.download.dir'] = '/tmp'
  firefox_profile['browser.download.folderList'] = 2
  # content-type of file that will be downloaded
  firefox_profile['browser.helperApps.neverAsk.saveToDisk'] = 'application/json;application/octet-stream;application/csv;text/csv;application/zip;application/x-zip;application/x-zip-compressed;application/x-rpm;application/pdf;application/xml;application/x-x509-ca-cert'
  firefox_profile['timeout'] = 480000
  firefox_profile['pdfjs.disabled'] = true
  firefox_profile['resynchronization_timeout'] = 90
  firefox_profile['resynchronize '] = true
  firefox_profile['dom.max_chrome_script_run_time'] = 0
  firefox_profile['dom.max_script_run_time'] = 0

  Capybara.default_selector = :css
  Capybara.ignore_hidden_elements = true
  reset_wait_time
  Capybara.run_server = false
  client = Selenium::WebDriver::Remote::Http::Default.new
  client.timeout = 240

  if ENV['LOCAL'] == 'true'
    STDOUT.puts 'starting local run'
    Capybara.default_driver = :firefox
    Capybara.register_driver :firefox do |app|
      begin
        STDOUT.puts 'Attempting to create browser instance'
        Capybara::Selenium::Driver.new(app, browser: :firefox, profile: firefox_profile, marionette: false, http_client: client)
      rescue => e
        STDOUT.puts 'Error: Failed Attempting to create browser instance'
        STDOUT.puts e
        STDOUT.puts e.backtrace
      end
    end

    begin
      page.driver.browser.manage.window.resize_to(1200, 1200)
    rescue => e
      STDOUT.puts 'Error: Failed resize browser'
      STDOUT.puts e
      STDOUT.puts e.backtrace
    end
end

错误堆栈跟踪-

starting local run
Attempting to create browser instance
Error: Failed resize browser
unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055)
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/firefox/launcher.rb:89:in `connect_until_stable'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/firefox/launcher.rb:53:in `block in launch'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/common/socket_lock.rb:41:in `locked'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/firefox/launcher.rb:49:in `launch'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/firefox/legacy/driver.rb:47:in `initialize'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/firefox/driver.rb:35:in `new'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/firefox/driver.rb:35:in `new'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/common/driver.rb:54:in `for'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver.rb:86:in `for'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/capybara-2.18.0/lib/capybara/selenium/driver.rb:23:in `browser'
/home/rubyuser/web-automation/cucumber/support/env.rb:63:in `block in <top (required)>'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-3.1.2/lib/cucumber/glue/invoke_in_world.rb:39:in `instance_exec'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-3.1.2/lib/cucumber/glue/invoke_in_world.rb:39:in `block in cucumber_instance_exec_in'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-3.1.2/lib/cucumber/glue/invoke_in_world.rb:54:in `cucumber_run_with_backtrace_filtering'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-3.1.2/lib/cucumber/glue/invoke_in_world.rb:27:in `cucumber_instance_exec_in'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-3.1.2/lib/cucumber/glue/hook.rb:21:in `invoke'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-3.1.2/lib/cucumber/runtime/before_hooks.rb:23:in `block (2 levels) in before_hooks'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/action.rb:24:in `execute'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/step.rb:32:in `execute'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/runner.rb:104:in `execute'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/runner.rb:51:in `execute'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/runner.rb:27:in `test_step'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/step.rb:17:in `describe_to'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/case.rb:28:in `block (3 levels) in describe_to'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/case.rb:27:in `each'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/case.rb:27:in `block (2 levels) in describe_to'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-3.1.2/lib/cucumber/filters/prepare_world.rb:22:in `block in test_case'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/around_hook.rb:17:in `execute'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/runner.rb:104:in `execute'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/runner.rb:51:in `execute'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/runner.rb:34:in `around_hook'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/around_hook.rb:12:in `describe_to'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/case.rb:120:in `block (2 levels) in compose_around_hooks'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/case.rb:121:in `compose_around_hooks'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/case.rb:26:in `block in describe_to'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/runner.rb:19:in `test_case'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/case.rb:25:in `describe_to'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-3.1.2/lib/cucumber/filters/prepare_world.rb:11:in `test_case'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/case.rb:25:in `describe_to'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/filter.rb:57:in `test_case'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-3.1.2/lib/cucumber/filters/retry.rb:18:in `test_case'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/case.rb:25:in `describe_to'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-3.1.2/lib/cucumber/filters/quit.rb:12:in `test_case'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/case.rb:25:in `describe_to'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-3.1.2/lib/cucumber/filters/broadcast_test_run_started_event.rb:21:in `block in done'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-3.1.2/lib/cucumber/filters/broadcast_test_run_started_event.rb:20:in `map'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-3.1.2/lib/cucumber/filters/broadcast_test_run_started_event.rb:20:in `done'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/filter.rb:62:in `done'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/filter.rb:62:in `done'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/filter.rb:62:in `done'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/filter.rb:62:in `done'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/filter.rb:62:in `done'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/filters/locations_filter.rb:20:in `done'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/filter.rb:62:in `done'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/test/filters/tag_filter.rb:18:in `done'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/compiler.rb:24:in `done'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core/gherkin/parser.rb:39:in `done'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core.rb:32:in `parse'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-core-3.2.1/lib/cucumber/core.rb:21:in `compile'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-3.1.2/lib/cucumber/runtime.rb:75:in `run!'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-3.1.2/lib/cucumber/cli/main.rb:34:in `execute!'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cucumber-3.1.2/lib/cucumber/cli/main.rb:13:in `execute'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cukeforker-2.1.1/lib/cukeforker/worker.rb:96:in `execute_cucumber'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cukeforker-2.1.1/lib/cukeforker/worker.rb:41:in `block in start'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cukeforker-2.1.1/lib/cukeforker/worker.rb:35:in `fork'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cukeforker-2.1.1/lib/cukeforker/worker.rb:35:in `start'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cukeforker-2.1.1/lib/cukeforker/worker_queue.rb:116:in `start'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cukeforker-2.1.1/lib/cukeforker/worker_queue.rb:53:in `fill'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cukeforker-2.1.1/lib/cukeforker/worker_queue.rb:35:in `process'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cukeforker-2.1.1/lib/cukeforker/runner.rb:120:in `process'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cukeforker-2.1.1/lib/cukeforker/runner.rb:100:in `run'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/gems/cukeforker-2.1.1/lib/cukeforker/runner.rb:40:in `run'
/home/rubyuser/web-automation/cucumber/Rakefile:48:in `concurrent_test'
/home/rubyuser/web-automation/cucumber/Rakefile:16:in `block in <top (required)>'
/home/rubyuser/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.0/lib/rake/task.rb:251:in `block in execute'
/home/rubyuser/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.0/lib/rake/task.rb:251:in `each'
/home/rubyuser/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.0/lib/rake/task.rb:251:in `execute'
/home/rubyuser/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.0/lib/rake/task.rb:195:in `block in invoke_with_call_chain'
/home/rubyuser/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
/home/rubyuser/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.0/lib/rake/task.rb:188:in `invoke_with_call_chain'
/home/rubyuser/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.0/lib/rake/task.rb:181:in `invoke'
/home/rubyuser/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.0/lib/rake/application.rb:160:in `invoke_task'
/home/rubyuser/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.0/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/home/rubyuser/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.0/lib/rake/application.rb:116:in `each'
/home/rubyuser/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.0/lib/rake/application.rb:116:in `block in top_level'
/home/rubyuser/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.0/lib/rake/application.rb:125:in `run_with_threads'
/home/rubyuser/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.0/lib/rake/application.rb:110:in `top_level'
/home/rubyuser/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.0/lib/rake/application.rb:83:in `block in run'
/home/rubyuser/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.0/lib/rake/application.rb:186:in `standard_exception_handling'
/home/rubyuser/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.0/lib/rake/application.rb:80:in `run'
/home/rubyuser/.rvm/gems/ruby-2.5.1@global/gems/rake-12.3.0/exe/rake:27:in `<top (required)>'
/home/rubyuser/.rvm/gems/ruby-2.5.1@global/bin/rake:23:in `load'
/home/rubyuser/.rvm/gems/ruby-2.5.1@global/bin/rake:23:in `<main>'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/bin/ruby_executable_hooks:24:in `eval'
/home/rubyuser/.rvm/gems/ruby-2.5.1@web-automation/bin/ruby_executable_hooks:24:in `<main>'

1 个答案:

答案 0 :(得分:1)

我知道您说过您不想被告知要更新浏览器版本,但是解决方案实际上将花费时间来更新所有测试项目。您提到的每个宝石的版本都已过时,此后所有提及的宝石都进行了大量的稳定性和时序改进。

从技术上讲,您实际上正在运行的Firefox版本从未真正使用本机Firefox驱动程序得到Selenium的支持,因为Selenium那时已开始专注于WebDriver(geckodriver)。真正的解决方案实际上是更新。