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

Pass options to driven_by #28341

Merged
merged 1 commit into from
Mar 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions actionpack/lib/action_dispatch/system_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def self.start_application # :nodoc:
# driven_by :selenium, using: :firefox
#
# driven_by :selenium, screen_size: [800, 800]
def self.driven_by(driver, using: :chrome, screen_size: [1400, 1400])
@driver = SystemTesting::Driver.new(driver, using: using, screen_size: screen_size)
def self.driven_by(driver, using: :chrome, screen_size: [1400, 1400], options: {})
@driver = SystemTesting::Driver.new(driver, using: using, screen_size: screen_size, options: options)
end

# Returns the driver object for the initialized system test
Expand Down
3 changes: 2 additions & 1 deletion actionpack/lib/action_dispatch/system_testing/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def initialize(name, **options)
@name = name
@browser = options[:using]
@screen_size = options[:screen_size]
@options = options[:options]
end

def use
Expand All @@ -19,7 +20,7 @@ def selenium?

def register
Capybara.register_driver @name do |app|
Capybara::Selenium::Driver.new(app, browser: @browser).tap do |driver|
Capybara::Selenium::Driver.new(app, { browser: @browser }.merge(@options)).tap do |driver|
driver.browser.manage.window.size = Selenium::WebDriver::Dimension.new(*@screen_size)
end
end
Expand Down
3 changes: 2 additions & 1 deletion actionpack/test/dispatch/system_testing/driver_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ class DriverTest < ActiveSupport::TestCase
end

test "initializing the driver with a browser" do
driver = ActionDispatch::SystemTesting::Driver.new(:selenium, using: :chrome, screen_size: [1400, 1400])
driver = ActionDispatch::SystemTesting::Driver.new(:selenium, using: :chrome, screen_size: [1400, 1400], options: { url: "http://example.com/wd/hub" })
assert_equal :selenium, driver.instance_variable_get(:@name)
assert_equal :chrome, driver.instance_variable_get(:@browser)
assert_equal [1400, 1400], driver.instance_variable_get(:@screen_size)
assert_equal ({ url: "http://example.com/wd/hub" }), driver.instance_variable_get(:@options)
end

test "selenium? returns false if driver is poltergeist" do
Expand Down