Skip to content

Conversation

@dvarrui
Copy link
Contributor

@dvarrui dvarrui commented Aug 7, 2023

[Fix] Missing to load the "net/http" library.

Description

Get this error

Using the selenium-webdriver v4.11.0 gem results in the following error: selenium-webdriver-4.11.0/lib/selenium/webdriver/remote/http/default.rb:108:in `new_request_for': uninitialized constant S elenium::WebDriver::Remote::Http::Default::Net (NameError)

             req = Net::HTTP.const_get(verb.to_s.capitalize).new(url.path, headers)

Motivation and Context

Software installed:

  • rbenv 1.2.0-48-g6717c62
  • ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [x86_64-linux]
  • geckodriver v0.33.0
  • gem selenium-webdriver (4.11.0)

When running this script:

require "selenium-webdriver"

# Initialize webdriver
options = Selenium::WebDriver::Options.firefox
options.page_load_strategy = :normal
driver = Selenium::WebDriver.for :firefox, options: options
driver.manage.timeouts.implicit_wait = 30

# Use webdriver
driver.get "https://www.nba.com"
puts "[Title] #{driver.title}"
driver.quit

Obtain this error:

selenium-webdriver-4.11.0/lib/selenium/webdriver/remote/http/default.rb:108:in `new_request_for': uninitialized constant S
elenium::WebDriver::Remote::Http::Default::Net (NameError)

            req = Net::HTTP.const_get(verb.to_s.capitalize).new(url.path, headers)

Solution

Adding require 'net/https' to the lib/selenium/webdriver/firefox.rb file.

Types of changes

[X ] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • [X ] I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@titusfortner
Copy link
Member

What do you think about the comment I made on the previous PR?

#12493 (comment)

@dvarrui
Copy link
Contributor Author

dvarrui commented Aug 7, 2023

I think what you propose is a good idea.
:-)

@titusfortner
Copy link
Member

@dvarrui would you like to make the change and I'll merge it?

@dvarrui
Copy link
Contributor Author

dvarrui commented Aug 7, 2023

OK

Do I make the modification in the same "fix_dvarrui" branch or should I create a new one?

@titusfortner
Copy link
Member

this branch is fine. We end up squashing and merging when we accept the PR.

@dvarrui
Copy link
Contributor Author

dvarrui commented Aug 7, 2023

Done!
Thanks for your help!

@titusfortner
Copy link
Member

This code does not need to be rebased with trunk, Github will do that automatically when it merges. I can't accept this PR without seeing the completed test run, and the results go away every time it gets rebased. 😂

dvarrui added 2 commits August 8, 2023 15:23
Body of commit message is a few lines of text, explaining things
in more detail, possibly giving some background about the issue
being fixed, etc.

The body of the commit message can be several paragraphs, and
please do proper word-wrap and keep columns shorter than about
72 characters or so. That way `git log` will show things
nicely even when it is indented.

Fixes #141Solve error: Missing to load the "net/http" library.

Error description:
Using the selenium-webdriver v4.11.0 gem results in the following error:
selenium-webdriver-4.11.0/lib/selenium/webdriver/remote/http/default.rb:108:in `new_request_for': uninitialized constant S
elenium::WebDriver::Remote::Http::Default::Net (NameError)

             req = Net::HTTP.const_get(verb.to_s.capitalize).new(url.path, headers)

Solution:
The problem is fixed by adding `require 'net/https'` to the `lib/selenium/webdriver/firefox.rb` file.
…ic one.

moving "require 'net/http'" to "lib/selenium/webdriver.rb"
so could be usedso that it can be used by all browsers
@dvarrui
Copy link
Contributor Author

dvarrui commented Aug 8, 2023

Sorry!
😞

@titusfortner
Copy link
Member

It's all good, I keep forgetting to go back and look at results 😂
All working, thanks!.

@titusfortner titusfortner merged commit d5a66c3 into SeleniumHQ:trunk Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants