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

Use load_selenium class method for requiring selenium-webdriver. #2013

Merged
merged 2 commits into from
Apr 16, 2018
Merged

Use load_selenium class method for requiring selenium-webdriver. #2013

merged 2 commits into from
Apr 16, 2018

Conversation

darraghbuckley
Copy link
Contributor

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).

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.
@darraghbuckley
Copy link
Contributor Author

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!

@@ -38,7 +55,7 @@ def browser
end

def initialize(app, **options)
load_selenium
Capybara::Selenium::Driver.load_selenium
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.class.load_selenium

@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'spec_helper'
require 'selenium-webdriver'
Copy link
Member

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

@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'spec_helper'
require "selenium-webdriver"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

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
Copy link
Member

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

@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'spec_helper'
require "selenium-webdriver"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

@@ -1,10 +1,10 @@
# frozen_string_literal: true

require 'spec_helper'
require "selenium-webdriver"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

@twalpole
Copy link
Member

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.
@darraghbuckley
Copy link
Contributor Author

Updated -- thanks again for Capybara!

@twalpole twalpole merged commit 431482b into teamcapybara:master Apr 16, 2018
@twalpole
Copy link
Member

twalpole commented Apr 16, 2018

Thanks for this, and you're welcome

twalpole pushed a commit that referenced this pull request Apr 16, 2018
…2013)

* Use `load_selenium` class method for requiring `selenium-webdriver`.

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.
@darraghbuckley darraghbuckley deleted the darragh-selenium-webdriver-20180414 branch April 16, 2018 19:31
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.

None yet

2 participants