Skip to content

Instantly share code, notes, and snippets.

@snickell
Last active August 27, 2024 14:20
Show Gist options
  • Save snickell/326d67e2b7d377e5a3a16e979352dd87 to your computer and use it in GitHub Desktop.
Save snickell/326d67e2b7d377e5a3a16e979352dd87 to your computer and use it in GitHub Desktop.
Repro Firefox VM not starting on SauceLabs with selenium-webdriver 4.23.0

Setup:

  1. run bundle install
  2. Set env vars SAUCELABS_USERNAME and SAUCELABS_AUTHKEY appropriately.

Repro:

  1. To repro the issue run: bundle exec ./sauce_firefox_repro.rb --platformName="Windows 10"
  2. To see it pass : bundle exec ./sauce_firefox_repro.rb --platformName="Windows 11"

Example of Failing with Windows 10

➜  sauce_firefox_repro bundle exec ./sauce_firefox_repro.rb --platformName="Windows 10"
Using platformName=Windows 10, we expect this to hang & fail
creating driver
# LONG HANG HERE while sauce UI fluctuates between "running and queued" back and forth
bundler: failed to load command: ./sauce_firefox_repro.rb (./sauce_firefox_repro.rb)
/Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/remote/response.rb:56:in `assert_ok': status code 500; payload {"status"=>13, "sessionId"=>"75985c4e106d43e4b37781c259723974", "value"=>{"message"=>"Infrastructure Error -- The Sauce VM failed to prepare for this test.\\nFor help, please check https://docs.saucelabs.com/dev/error-messages"}} (Selenium::WebDriver::Error::ServerError)
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/remote/response.rb:34:in `initialize'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/remote/http/common.rb:101:in `new'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/remote/http/common.rb:101:in `create_response'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/remote/http/default.rb:103:in `request'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/remote/http/default.rb:100:in `request'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/remote/http/default.rb:100:in `request'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/remote/http/default.rb:100:in `request'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/remote/http/default.rb:100:in `request'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/remote/http/default.rb:100:in `request'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/remote/http/default.rb:100:in `request'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/remote/http/common.rb:67:in `call'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/remote/bridge.rb:675:in `execute'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/remote/bridge.rb:76:in `create_session'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/common/driver.rb:323:in `block in create_bridge'
        from <internal:kernel>:90:in `tap'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/common/driver.rb:322:in `create_bridge'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/common/driver.rb:73:in `initialize'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/remote/driver.rb:38:in `initialize'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/common/driver.rb:57:in `new'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver/common/driver.rb:57:in `for'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/selenium-webdriver-4.23.0/lib/selenium/webdriver.rb:89:in `for'
        from /Users/seth/src/sauce_firefox_repro/sauce_firefox_repro.rb:34:in `<top (required)>'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.3.22/lib/bundler/cli/exec.rb:58:in `load'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.3.22/lib/bundler/cli/exec.rb:58:in `kernel_load'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.3.22/lib/bundler/cli/exec.rb:23:in `run'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.3.22/lib/bundler/cli.rb:486:in `exec'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.3.22/lib/bundler/cli.rb:31:in `dispatch'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.3.22/lib/bundler/cli.rb:25:in `start'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.3.22/exe/bundle:48:in `block in <top (required)>'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.3.22/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
        from /Users/seth/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.3.22/exe/bundle:36:in `<top (required)>'
        from /Users/seth/.rbenv/versions/3.0.5/bin/bundle:23:in `load'
        from /Users/seth/.rbenv/versions/3.0.5/bin/bundle:23:in `<main>'

Example of passing with Windows 11

➜  sauce_firefox_repro bundle exec ./sauce_firefox_repro.rb --platformName="Windows 11"
Using platformName=Windows 11
creating driver
doing driver.get
doing driver.find_element
Table with id=hnmain found.
source 'https://rubygems.org'
gem 'selenium-webdriver', '~> 4.23.0'
#!/usr/bin/env ruby
# SETUP: run `bundle install`
#
# To repro the issue run: `bundle exec ./sauce_firefox_repro.rb --platformName="Windows 10"`
# To see it pass : `bundle exec ./sauce_firefox_repro.rb --platformName="Windows 11"`
require 'selenium-webdriver'
SAUCELABS_USERNAME = ENV.fetch('SAUCELABS_USERNAME', nil)
SAUCELABS_AUTHKEY = ENV.fetch('SAUCELABS_AUTHKEY', nil)
raise "Missing SauceLabs credentials, set env vars SAUCELABS_USERNAME and SAUCELABS_AUTHKEY" if SAUCELABS_USERNAME.nil? || SAUCELABS_AUTHKEY.nil?
args = ARGV.find { |arg| arg.start_with?("--platformName=") }
platform_name = args ? args.split("=").last : "Windows 10"
print "Using platformName=#{platform_name}#{', we expect this to hang & fail' if platform_name == 'Windows 10'}\n"
sauce_url = "http://#{SAUCELABS_USERNAME}:#{SAUCELABS_AUTHKEY}@ondemand.us-west-1.saucelabs.com:80/wd/hub"
capabilities = {
'browserName': "firefox",
'browserVersion': "112",
# 'platform': "Windows 10", # Hangs and fails
# 'platform': "Windows 11", # Succeeds
'platformName': platform_name,
'sauce:options': {
name: 'firefox-repro',
tags: ['firefox-repro'],
idleTimeout: 60,
seleniumVersion: Selenium::WebDriver::VERSION,
}
}
puts "creating driver"
driver = Selenium::WebDriver.for(:remote,
url: sauce_url,
capabilities: Selenium::WebDriver::Remote::Capabilities.new(capabilities)
)
begin
puts "doing driver.get"
driver.get 'https://news.ycombinator.com'
puts "doing driver.find_element"
if driver.find_element(id: 'hnmain')
puts "Table with id=hnmain found."
else
puts "Table with id=hnmain not found."
end
ensure
driver.quit
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment