mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Rename methods and update docs
This is a minor update to the named methods for the following: - s/desired_capabilities/capabilities - s/driver_options/capabilities Since they are all the same thing we should keep the name the same throughout the feature. Updated docs to match / be a little bit clearer Also updated the Gemfile for selenium-webdriver.
This commit is contained in:
parent
5936bd9a20
commit
1a4f613072
5 changed files with 33 additions and 25 deletions
15
Gemfile.lock
15
Gemfile.lock
|
@ -238,10 +238,10 @@ GEM
|
||||||
faye-websocket (0.10.7)
|
faye-websocket (0.10.7)
|
||||||
eventmachine (>= 0.12.0)
|
eventmachine (>= 0.12.0)
|
||||||
websocket-driver (>= 0.5.1)
|
websocket-driver (>= 0.5.1)
|
||||||
ffi (1.9.25)
|
ffi (1.10.0)
|
||||||
ffi (1.9.25-java)
|
ffi (1.10.0-java)
|
||||||
ffi (1.9.25-x64-mingw32)
|
ffi (1.10.0-x64-mingw32)
|
||||||
ffi (1.9.25-x86-mingw32)
|
ffi (1.10.0-x86-mingw32)
|
||||||
fugit (1.1.6)
|
fugit (1.1.6)
|
||||||
et-orbi (~> 1.1, >= 1.1.6)
|
et-orbi (~> 1.1, >= 1.1.6)
|
||||||
raabro (~> 1.1)
|
raabro (~> 1.1)
|
||||||
|
@ -336,6 +336,7 @@ GEM
|
||||||
mysql2 (0.5.2-x64-mingw32)
|
mysql2 (0.5.2-x64-mingw32)
|
||||||
mysql2 (0.5.2-x86-mingw32)
|
mysql2 (0.5.2-x86-mingw32)
|
||||||
nio4r (2.3.1)
|
nio4r (2.3.1)
|
||||||
|
nio4r (2.3.1-java)
|
||||||
nokogiri (1.9.1)
|
nokogiri (1.9.1)
|
||||||
mini_portile2 (~> 2.4.0)
|
mini_portile2 (~> 2.4.0)
|
||||||
nokogiri (1.9.1-java)
|
nokogiri (1.9.1-java)
|
||||||
|
@ -432,9 +433,9 @@ GEM
|
||||||
tilt (>= 1.1, < 3)
|
tilt (>= 1.1, < 3)
|
||||||
sdoc (1.0.0)
|
sdoc (1.0.0)
|
||||||
rdoc (>= 5.0)
|
rdoc (>= 5.0)
|
||||||
selenium-webdriver (3.141.0)
|
selenium-webdriver (3.5.2)
|
||||||
childprocess (~> 0.5)
|
childprocess (~> 0.5)
|
||||||
rubyzip (~> 1.2, >= 1.2.2)
|
rubyzip (~> 1.0)
|
||||||
sequel (5.14.0)
|
sequel (5.14.0)
|
||||||
serverengine (2.0.7)
|
serverengine (2.0.7)
|
||||||
sigdump (~> 0.2.2)
|
sigdump (~> 0.2.2)
|
||||||
|
@ -509,6 +510,8 @@ GEM
|
||||||
websocket (1.2.8)
|
websocket (1.2.8)
|
||||||
websocket-driver (0.7.0)
|
websocket-driver (0.7.0)
|
||||||
websocket-extensions (>= 0.1.0)
|
websocket-extensions (>= 0.1.0)
|
||||||
|
websocket-driver (0.7.0-java)
|
||||||
|
websocket-extensions (>= 0.1.0)
|
||||||
websocket-extensions (0.1.3)
|
websocket-extensions (0.1.3)
|
||||||
xpath (3.2.0)
|
xpath (3.2.0)
|
||||||
nokogiri (~> 1.8)
|
nokogiri (~> 1.8)
|
||||||
|
|
|
@ -89,12 +89,16 @@ module ActionDispatch
|
||||||
# { js_errors: true }
|
# { js_errors: true }
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# Most drivers won't let you add specific browser capabilities through the +options+ mentioned above.
|
# Some drivers require browser capabilities to be passed as a block instead
|
||||||
# As an example, if you want to add mobile emulation on chrome, you'll have to create an instance of selenium's
|
# of through the +options+ hash.
|
||||||
# `Chrome::Options` object and add capabilities to it.
|
#
|
||||||
# To make things easier, `driven_by` can be called with a block.
|
# As an example, if you want to add mobile emulation on chrome, you'll have to
|
||||||
# The block will be passed an instance of `<Driver>::Options` where you can define the capabilities you want.
|
# create an instance of selenium's `Chrome::Options` object and add
|
||||||
# Please refer to your driver documentation to learn about supported options.
|
# capabilities with a block.
|
||||||
|
#
|
||||||
|
# The block will be passed an instance of `<Driver>::Options` where you can
|
||||||
|
# define the capabilities you want. Please refer to your driver documentation
|
||||||
|
# to learn about supported options.
|
||||||
#
|
#
|
||||||
# class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
# class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
||||||
# driven_by :chrome, screen_size: [1024, 768] do |driver_option|
|
# driven_by :chrome, screen_size: [1024, 768] do |driver_option|
|
||||||
|
@ -148,10 +152,10 @@ module ActionDispatch
|
||||||
# driven_by :selenium, using: :firefox
|
# driven_by :selenium, using: :firefox
|
||||||
#
|
#
|
||||||
# driven_by :selenium, using: :headless_firefox
|
# driven_by :selenium, using: :headless_firefox
|
||||||
def self.driven_by(driver, using: :chrome, screen_size: [1400, 1400], options: {}, &desired_capabilities)
|
def self.driven_by(driver, using: :chrome, screen_size: [1400, 1400], options: {}, &capabilities)
|
||||||
driver_options = { using: using, screen_size: screen_size, options: options }
|
driver_options = { using: using, screen_size: screen_size, options: options }
|
||||||
|
|
||||||
self.driver = SystemTesting::Driver.new(driver, driver_options, &desired_capabilities)
|
self.driver = SystemTesting::Driver.new(driver, driver_options, &capabilities)
|
||||||
end
|
end
|
||||||
|
|
||||||
driven_by :selenium
|
driven_by :selenium
|
||||||
|
|
|
@ -29,7 +29,7 @@ module ActionDispatch
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def driver_options
|
def capabilities
|
||||||
@option ||= case type
|
@option ||= case type
|
||||||
when :chrome
|
when :chrome
|
||||||
Selenium::WebDriver::Chrome::Options.new
|
Selenium::WebDriver::Chrome::Options.new
|
||||||
|
@ -40,16 +40,16 @@ module ActionDispatch
|
||||||
|
|
||||||
private
|
private
|
||||||
def headless_chrome_browser_options
|
def headless_chrome_browser_options
|
||||||
driver_option.args << "--headless"
|
capability.args << "--headless"
|
||||||
driver_option.args << "--disable-gpu" if Gem.win_platform?
|
capability.args << "--disable-gpu" if Gem.win_platform?
|
||||||
|
|
||||||
driver_options
|
capabilities
|
||||||
end
|
end
|
||||||
|
|
||||||
def headless_firefox_browser_options
|
def headless_firefox_browser_options
|
||||||
driver_options.args << "-headless"
|
capabilities.args << "-headless"
|
||||||
|
|
||||||
driver_options
|
capabilities
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
module ActionDispatch
|
module ActionDispatch
|
||||||
module SystemTesting
|
module SystemTesting
|
||||||
class Driver # :nodoc:
|
class Driver # :nodoc:
|
||||||
def initialize(name, **options, &desired_capabilities)
|
def initialize(name, **options, &capabilities)
|
||||||
@name = name
|
@name = name
|
||||||
@browser = Browser.new(options[:using])
|
@browser = Browser.new(options[:using])
|
||||||
@screen_size = options[:screen_size]
|
@screen_size = options[:screen_size]
|
||||||
@options = options[:options]
|
@options = options[:options]
|
||||||
@desired_capabilities = desired_capabilities
|
@capabilities = capabilities
|
||||||
end
|
end
|
||||||
|
|
||||||
def use
|
def use
|
||||||
|
@ -23,7 +23,7 @@ module ActionDispatch
|
||||||
end
|
end
|
||||||
|
|
||||||
def register
|
def register
|
||||||
define_browser_capabilities(@browser.driver_options)
|
define_browser_capabilities(@browser.capabilities)
|
||||||
|
|
||||||
Capybara.register_driver @name do |app|
|
Capybara.register_driver @name do |app|
|
||||||
case @name
|
case @name
|
||||||
|
@ -34,8 +34,8 @@ module ActionDispatch
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def define_browser_capabilities(driver_options)
|
def define_browser_capabilities(capabilities)
|
||||||
@desired_capabilities.call(driver_options) if @desired_capabilities
|
@capabilities.call(capabilities) if @capabilities
|
||||||
end
|
end
|
||||||
|
|
||||||
def browser_options
|
def browser_options
|
||||||
|
|
|
@ -771,6 +771,7 @@ module ApplicationTests
|
||||||
def test_reset_sessions_on_failed_system_test_screenshot
|
def test_reset_sessions_on_failed_system_test_screenshot
|
||||||
app_file "test/system/reset_sessions_on_failed_system_test_screenshot_test.rb", <<~RUBY
|
app_file "test/system/reset_sessions_on_failed_system_test_screenshot_test.rb", <<~RUBY
|
||||||
require "application_system_test_case"
|
require "application_system_test_case"
|
||||||
|
require "selenium/webdriver"
|
||||||
|
|
||||||
class ResetSessionsOnFailedSystemTestScreenshotTest < ApplicationSystemTestCase
|
class ResetSessionsOnFailedSystemTestScreenshotTest < ApplicationSystemTestCase
|
||||||
ActionDispatch::SystemTestCase.class_eval do
|
ActionDispatch::SystemTestCase.class_eval do
|
||||||
|
|
Loading…
Reference in a new issue