Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby 3.0.1 - uninitialized constant Selenium::WebDriver::ServiceManager::URI #9825

Closed
flanger001 opened this issue Sep 14, 2021 · 2 comments · Fixed by #9827
Closed

Ruby 3.0.1 - uninitialized constant Selenium::WebDriver::ServiceManager::URI #9825

flanger001 opened this issue Sep 14, 2021 · 2 comments · Fixed by #9827
Labels

Comments

@flanger001
Copy link
Contributor

flanger001 commented Sep 14, 2021

🐛 Bug Report

On Ruby 3.0.1, when the stdlib uri package has not already been required, selenium-webdriver v4.0.0.rc1 throws this error when creating a browser driver:

/path/to/project/selenium/.bundle/ruby/3.0.0/gems/selenium-webdriver-4.0.0.rc1/lib/selenium/webdriver/common/service_manager.rb:73:in `uri': uninitialized constant Selenium::WebDriver::ServiceManager::URI (NameError)

This can be fixed by including the line require "uri" at this line: https://github.com/SeleniumHQ/selenium/blob/trunk/rb/lib/selenium/webdriver.rb#L26, which I will open a PR for shortly.

To Reproduce

Executable steps are below, but this is the plain-language general idea:

  • Create and navigate to a project directory
  • Initialize a Gemfile
  • Add a local Bundler configuration
  • Install gems
  • Create a Ruby script requiring selenium-webdriver and initializing a browser driver
  • Run the script with bundle exec

Expected behavior

  • Firefox window appears briefly and then disappears
  • Program runs without errors

Test script or set of commands reproducing this issue

Installing a geckodriver binary - skip if not needed

# Change this for your architecture - I'm on an M1 Mac (https://github.com/mozilla/geckodriver/releases)
geckodriver_url="https://github.com/mozilla/geckodriver/releases/download/v0.29.1/geckodriver-v0.29.1-macos-aarch64.tar.gz"
geckodriver_path="$HOME/Downloads/geckodriver.tar.gz"
# Change this to a directory where `geckodriver` will be available to your `PATH`
geckodriver_target="$HOME/scripts"

mkdir -p $geckodriver_target
curl -L $geckodriver_url -o $geckodriver_path
gzip -d $geckodriver_path --stdout | tar -xvf  -C $geckodriver_target

unset geckodriver_url
unset geckodriver_path

Reproduction script

mkdir -p selenium_test && cd $_
bundle init
bundle config --local set path .bundle

cat << GEMFILE > Gemfile
# frozen_string_literal: true

source "https://rubygems.org"

ruby "3.0.1"

gem "selenium-webdriver", "4.0.0.rc1"
GEMFILE

bundle install

echo 3.0.1 > .ruby-version

cat << RB > test.rb
require "selenium-webdriver"
browser = Selenium::WebDriver.for(:firefox)
RB

bundle exec ruby test.rb

Environment

OS: macOS 11.5.2
Browser: Firefox
Browser version: 92.0 build 20210903235534
Browser Driver version: geckodriver 0.29.1 (970ef713fe58 2021-04-08 23:34 +0200)
Language Bindings version: Ruby 3.0.1

@ghost ghost added the needs-triaging label Sep 14, 2021
flanger001 added a commit to flanger001/selenium that referenced this issue Sep 14, 2021
`URI` was gemified in Ruby 2.7 ruby/uri@a4a1d4c and therefore must be manually required to use.

Fixes SeleniumHQ#9825
@flanger001
Copy link
Contributor Author

Bump - I modified the repro script to be a bit more idempotent.

titusfortner pushed a commit that referenced this issue Sep 22, 2021
`URI` was gemified in Ruby 2.7 ruby/uri@a4a1d4c and therefore must be manually required to use.

Fixes #9825
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants