-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Use load_selenium
class method for requiring selenium-webdriver
.
#2013
Use load_selenium
class method for requiring selenium-webdriver
.
#2013
Conversation
This change relates to this issue: #2011 `Capybara::Selenium::Driver#load_selenium` is bumped to a class method which is called either during `Selenium::Driver` instantiation or before Selenium is used. Tests have also been updated to remove now unnecessary requires of `selenium-webdriver`. This should make `Selenium::Driver` behave more like `RackTest::Driver`. It also has the benefit of making sure the misnamed Selenium errors are patched ~everywhere. This change passes local tests for me that were run with: `bundle exec rake chrome_spec` `CI=true bundle exec rake travis` All in all, I'm not sure the lazy-loading is worthwhile (though that's, of course, a choice for the maintainers). A small aside, that there's also the use of the `webdrivers` gem which is conditional on the `CI` environment variable. This means that CI behaves differently to other environments in a way that's perhaps not expected (though the failure case looks to be that tests would succeed in CI but fail locally, which seems better than the opposite). Maintainers, if this isn't the direction you want to go feel free to close the pull request without merging.
Maintainers, if this isn't the direction you want to go feel free to close the pull request without merging. Let me know if there's anything I can do to help and thanks for Capybara! |
lib/capybara/selenium/driver.rb
Outdated
@@ -38,7 +55,7 @@ def browser | |||
end | |||
|
|||
def initialize(app, **options) | |||
load_selenium | |||
Capybara::Selenium::Driver.load_selenium |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.class.load_selenium
spec/selenium_spec_chrome.rb
Outdated
@@ -1,7 +1,6 @@ | |||
# frozen_string_literal: true | |||
|
|||
require 'spec_helper' | |||
require 'selenium-webdriver' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave these - Sometimes we want to access things from Selenium before the driver is initialized
spec/selenium_spec_edge.rb
Outdated
@@ -1,7 +1,6 @@ | |||
# frozen_string_literal: true | |||
|
|||
require 'spec_helper' | |||
require "selenium-webdriver" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above
spec/selenium_spec_ie.rb
Outdated
require 'shared_selenium_session' | ||
require 'rspec/shared_spec_matchers' | ||
|
||
Capybara.register_driver :selenium_ie do |app| | ||
# ::Selenium::WebDriver.logger.level = "debug" | ||
Capybara::Selenium::Driver.load_selenium |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't necessary since the Capybara::Selenium::Driver initialization calls it
spec/shared_selenium_session.rb
Outdated
@@ -1,7 +1,6 @@ | |||
# frozen_string_literal: true | |||
|
|||
require 'spec_helper' | |||
require "selenium-webdriver" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above
spec/selenium_spec_marionette.rb
Outdated
@@ -1,10 +1,10 @@ | |||
# frozen_string_literal: true | |||
|
|||
require 'spec_helper' | |||
require "selenium-webdriver" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above
I commented on some things, basically this is fine but I don't really want the changes to the test files - just leave them how they were. |
I'm leaving the quotation marks as they were, though they don't match others, to keep the change history clean.
Updated -- thanks again for Capybara! |
Thanks for this, and you're welcome |
This change relates to this issue:
#2011
Capybara::Selenium::Driver#load_selenium
is bumped to a class method which iscalled either during
Selenium::Driver
instantiation or before Selenium isused. Tests have also been updated to remove now unnecessary requires of
selenium-webdriver
.This should make
Selenium::Driver
behave more likeRackTest::Driver
. It alsohas the benefit of making sure the misnamed Selenium errors are patched
~everywhere.
This change passes local tests for me that were run with:
bundle exec rake chrome_spec
CI=true bundle exec rake travis
All in all, I'm not sure the lazy-loading is worthwhile (though that's, of
course, a choice for the maintainers).
A small aside, that there's also the use of the
webdrivers
gem which isconditional on the
CI
environment variable. This means that CI behavesdifferently to other environments in a way that's perhaps not expected (though
the failure case looks to be that tests would succeed in CI but fail locally,
which seems better than the opposite).