selenium-webdriver 4.0.0.alpha1 → 4.0.0.alpha6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGES +139 -1
- data/LICENSE +1 -1
- data/lib/selenium/server.rb +3 -3
- data/lib/selenium/webdriver.rb +11 -7
- data/lib/selenium/webdriver/atoms/findElements.js +122 -0
- data/lib/selenium/webdriver/atoms/getAttribute.js +84 -7
- data/lib/selenium/webdriver/atoms/isDisplayed.js +75 -77
- data/lib/selenium/webdriver/chrome.rb +10 -9
- data/lib/selenium/webdriver/chrome/bridge.rb +20 -4
- data/lib/selenium/webdriver/chrome/driver.rb +3 -52
- data/lib/selenium/webdriver/chrome/options.rb +97 -57
- data/lib/selenium/webdriver/chrome/profile.rb +2 -2
- data/lib/selenium/webdriver/chrome/service.rb +0 -4
- data/lib/selenium/webdriver/common.rb +3 -0
- data/lib/selenium/webdriver/common/driver.rb +76 -17
- data/lib/selenium/webdriver/common/driver_extensions/{has_touch_screen.rb → has_devtools.rb} +10 -8
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +2 -1
- data/lib/selenium/webdriver/common/logger.rb +48 -16
- data/lib/selenium/webdriver/common/manager.rb +5 -0
- data/lib/selenium/webdriver/common/options.rb +60 -121
- data/lib/selenium/webdriver/common/platform.rb +3 -0
- data/lib/selenium/webdriver/common/port_prober.rb +4 -6
- data/lib/selenium/webdriver/common/profile_helper.rb +10 -2
- data/lib/selenium/webdriver/common/proxy.rb +0 -0
- data/lib/selenium/webdriver/common/search_context.rb +3 -2
- data/lib/selenium/webdriver/common/service.rb +30 -113
- data/lib/selenium/webdriver/common/service_manager.rb +151 -0
- data/lib/selenium/webdriver/common/socket_lock.rb +2 -2
- data/lib/selenium/webdriver/common/wait.rb +1 -1
- data/lib/selenium/webdriver/devtools.rb +118 -0
- data/lib/selenium/webdriver/devtools/accessibility.rb +62 -0
- data/lib/selenium/webdriver/devtools/animation.rb +98 -0
- data/lib/selenium/webdriver/devtools/application_cache.rb +64 -0
- data/lib/selenium/webdriver/devtools/audits.rb +61 -0
- data/lib/selenium/webdriver/devtools/background_service.rb +67 -0
- data/lib/selenium/webdriver/devtools/browser.rb +123 -0
- data/lib/selenium/webdriver/devtools/cache_storage.rb +73 -0
- data/lib/selenium/webdriver/devtools/cast.rb +70 -0
- data/lib/selenium/webdriver/devtools/console.rb +57 -0
- data/lib/selenium/webdriver/devtools/css.rb +165 -0
- data/lib/selenium/webdriver/devtools/database.rb +64 -0
- data/lib/selenium/webdriver/devtools/debugger.rb +229 -0
- data/lib/selenium/webdriver/devtools/device_orientation.rb +53 -0
- data/lib/selenium/webdriver/devtools/dom.rb +320 -0
- data/lib/selenium/webdriver/devtools/domdebugger.rb +93 -0
- data/lib/selenium/webdriver/devtools/domsnapshot.rb +65 -0
- data/lib/selenium/webdriver/devtools/domstorage.rb +79 -0
- data/lib/selenium/webdriver/devtools/emulation.rb +180 -0
- data/lib/selenium/webdriver/devtools/fetch.rb +97 -0
- data/lib/selenium/webdriver/devtools/headless_experimental.rb +61 -0
- data/lib/selenium/webdriver/devtools/heap_profiler.rb +107 -0
- data/lib/selenium/webdriver/devtools/indexed_db.rb +100 -0
- data/lib/selenium/webdriver/devtools/input.rb +140 -0
- data/lib/selenium/webdriver/devtools/inspector.rb +55 -0
- data/lib/selenium/webdriver/devtools/io.rb +59 -0
- data/lib/selenium/webdriver/devtools/layer_tree.rb +95 -0
- data/lib/selenium/webdriver/devtools/log.rb +66 -0
- data/lib/selenium/webdriver/devtools/media.rb +57 -0
- data/lib/selenium/webdriver/devtools/memory.rb +86 -0
- data/lib/selenium/webdriver/devtools/network.rb +228 -0
- data/lib/selenium/webdriver/devtools/overlay.rb +157 -0
- data/lib/selenium/webdriver/devtools/page.rb +374 -0
- data/lib/selenium/webdriver/devtools/performance.rb +63 -0
- data/lib/selenium/webdriver/devtools/profiler.rb +111 -0
- data/lib/selenium/webdriver/devtools/runtime.rb +193 -0
- data/lib/selenium/webdriver/devtools/schema.rb +46 -0
- data/lib/selenium/webdriver/devtools/security.rb +71 -0
- data/lib/selenium/webdriver/devtools/service_worker.rb +116 -0
- data/lib/selenium/webdriver/devtools/storage.rb +95 -0
- data/lib/selenium/webdriver/devtools/system_info.rb +50 -0
- data/lib/selenium/webdriver/devtools/target.rb +141 -0
- data/lib/selenium/webdriver/devtools/tethering.rb +55 -0
- data/lib/selenium/webdriver/devtools/tracing.rb +76 -0
- data/lib/selenium/webdriver/devtools/web_audio.rb +70 -0
- data/lib/selenium/webdriver/devtools/web_authn.rb +94 -0
- data/lib/selenium/webdriver/edge.rb +29 -9
- data/lib/selenium/webdriver/{firefox/util.rb → edge_chrome/bridge.rb} +11 -20
- data/lib/selenium/webdriver/{common/w3c_options.rb → edge_chrome/driver.rb} +14 -17
- data/lib/selenium/webdriver/edge_chrome/options.rb +36 -0
- data/lib/selenium/webdriver/edge_chrome/profile.rb +33 -0
- data/lib/selenium/webdriver/edge_chrome/service.rb +36 -0
- data/lib/selenium/webdriver/{common/w3c_manager.rb → edge_html/driver.rb} +11 -17
- data/lib/selenium/webdriver/{edge → edge_html}/options.rb +26 -22
- data/lib/selenium/webdriver/{edge → edge_html}/service.rb +2 -6
- data/lib/selenium/webdriver/firefox.rb +18 -15
- data/lib/selenium/webdriver/firefox/bridge.rb +1 -1
- data/lib/selenium/webdriver/firefox/driver.rb +2 -30
- data/lib/selenium/webdriver/firefox/extension.rb +8 -0
- data/lib/selenium/webdriver/firefox/options.rb +47 -52
- data/lib/selenium/webdriver/firefox/profile.rb +7 -78
- data/lib/selenium/webdriver/firefox/service.rb +0 -4
- data/lib/selenium/webdriver/ie.rb +8 -7
- data/lib/selenium/webdriver/ie/driver.rb +0 -32
- data/lib/selenium/webdriver/ie/options.rb +10 -33
- data/lib/selenium/webdriver/ie/service.rb +5 -9
- data/lib/selenium/webdriver/remote.rb +16 -10
- data/lib/selenium/webdriver/remote/bridge.rb +34 -42
- data/lib/selenium/webdriver/remote/capabilities.rb +22 -6
- data/lib/selenium/webdriver/remote/driver.rb +6 -12
- data/lib/selenium/webdriver/remote/http/default.rb +9 -4
- data/lib/selenium/webdriver/remote/http/persistent.rb +5 -6
- data/lib/selenium/webdriver/safari.rb +9 -8
- data/lib/selenium/webdriver/safari/bridge.rb +4 -4
- data/lib/selenium/webdriver/safari/driver.rb +3 -29
- data/lib/selenium/webdriver/safari/options.rb +18 -19
- data/lib/selenium/webdriver/safari/service.rb +0 -4
- data/lib/selenium/webdriver/support.rb +1 -0
- data/lib/selenium/webdriver/support/cdp_client_generator.rb +77 -0
- data/lib/selenium/webdriver/support/color.rb +2 -2
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +1 -1
- data/lib/selenium/webdriver/support/relative_locator.rb +51 -0
- data/lib/selenium/webdriver/version.rb +1 -1
- data/selenium-webdriver.gemspec +5 -4
- metadata +81 -42
- data/lib/selenium/webdriver/common/bridge_helper.rb +0 -82
- data/lib/selenium/webdriver/common/keyboard.rb +0 -70
- data/lib/selenium/webdriver/common/mouse.rb +0 -89
- data/lib/selenium/webdriver/common/touch_action_builder.rb +0 -78
- data/lib/selenium/webdriver/common/touch_screen.rb +0 -123
- data/lib/selenium/webdriver/common/w3c_action_builder.rb +0 -212
- data/lib/selenium/webdriver/edge/bridge.rb +0 -76
- data/lib/selenium/webdriver/edge/driver.rb +0 -70
- data/lib/selenium/webdriver/firefox/binary.rb +0 -110
- data/lib/selenium/webdriver/firefox/extension/prefs.json +0 -69
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/launcher.rb +0 -111
- data/lib/selenium/webdriver/firefox/legacy/driver.rb +0 -83
- data/lib/selenium/webdriver/firefox/marionette/bridge.rb +0 -49
- data/lib/selenium/webdriver/firefox/marionette/driver.rb +0 -90
- data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
- data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
- data/lib/selenium/webdriver/remote/oss/bridge.rb +0 -594
- data/lib/selenium/webdriver/remote/oss/commands.rb +0 -223
- data/lib/selenium/webdriver/remote/w3c/bridge.rb +0 -605
- data/lib/selenium/webdriver/remote/w3c/capabilities.rb +0 -310
- data/lib/selenium/webdriver/remote/w3c/commands.rb +0 -157
@@ -17,25 +17,26 @@
|
|
17
17
|
# specific language governing permissions and limitations
|
18
18
|
# under the License.
|
19
19
|
|
20
|
-
require 'selenium/webdriver/ie/driver'
|
21
|
-
require 'selenium/webdriver/ie/options'
|
22
|
-
|
23
20
|
module Selenium
|
24
21
|
module WebDriver
|
25
22
|
module IE
|
23
|
+
autoload :Driver, 'selenium/webdriver/ie/driver'
|
24
|
+
autoload :Options, 'selenium/webdriver/ie/options'
|
25
|
+
autoload :Service, 'selenium/webdriver/ie/service'
|
26
|
+
|
26
27
|
def self.driver_path=(path)
|
27
28
|
WebDriver.logger.deprecate 'Selenium::WebDriver::IE#driver_path=',
|
28
|
-
'Selenium::WebDriver::IE::Service#driver_path='
|
29
|
+
'Selenium::WebDriver::IE::Service#driver_path=',
|
30
|
+
id: :driver_path
|
29
31
|
Selenium::WebDriver::IE::Service.driver_path = path
|
30
32
|
end
|
31
33
|
|
32
34
|
def self.driver_path
|
33
35
|
WebDriver.logger.deprecate 'Selenium::WebDriver::IE#driver_path',
|
34
|
-
'Selenium::WebDriver::IE::Service#driver_path'
|
36
|
+
'Selenium::WebDriver::IE::Service#driver_path',
|
37
|
+
id: :driver_path
|
35
38
|
Selenium::WebDriver::IE::Service.driver_path
|
36
39
|
end
|
37
40
|
end # IE
|
38
41
|
end # WebDriver
|
39
42
|
end # Selenium
|
40
|
-
|
41
|
-
require 'selenium/webdriver/ie/service'
|
@@ -31,41 +31,9 @@ module Selenium
|
|
31
31
|
include DriverExtensions::HasWebStorage
|
32
32
|
include DriverExtensions::TakesScreenshot
|
33
33
|
|
34
|
-
def initialize(opts = {})
|
35
|
-
opts[:desired_capabilities] = create_capabilities(opts)
|
36
|
-
|
37
|
-
opts[:url] ||= service_url(opts)
|
38
|
-
|
39
|
-
listener = opts.delete(:listener)
|
40
|
-
desired_capabilities = opts.delete(:desired_capabilities)
|
41
|
-
|
42
|
-
@bridge = Remote::Bridge.new(opts)
|
43
|
-
@bridge.create_session(desired_capabilities)
|
44
|
-
|
45
|
-
super(@bridge, listener: listener)
|
46
|
-
end
|
47
|
-
|
48
34
|
def browser
|
49
35
|
:internet_explorer
|
50
36
|
end
|
51
|
-
|
52
|
-
def quit
|
53
|
-
super
|
54
|
-
ensure
|
55
|
-
@service&.stop
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def create_capabilities(opts)
|
61
|
-
caps = opts.delete(:desired_capabilities) { Remote::Capabilities.internet_explorer }
|
62
|
-
options = opts.delete(:options) { Options.new }
|
63
|
-
options = options.as_json
|
64
|
-
caps.merge!(options) unless options.empty?
|
65
|
-
|
66
|
-
caps
|
67
|
-
end
|
68
|
-
|
69
37
|
end # Driver
|
70
38
|
end # IE
|
71
39
|
end # WebDriver
|
@@ -20,7 +20,7 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module IE
|
23
|
-
class Options
|
23
|
+
class Options < WebDriver::Options
|
24
24
|
KEY = 'se:ieOptions'
|
25
25
|
SCROLL_TOP = 0
|
26
26
|
SCROLL_BOTTOM = 1
|
@@ -41,6 +41,7 @@ module Selenium
|
|
41
41
|
use_per_process_proxy: 'ie.usePerProcessProxy',
|
42
42
|
validate_cookie_document_type: 'ie.validateCookieDocumentType'
|
43
43
|
}.freeze
|
44
|
+
BROWSER = 'internet_explorer'
|
44
45
|
|
45
46
|
CAPABILITIES.each_key do |key|
|
46
47
|
define_method key do
|
@@ -52,7 +53,7 @@ module Selenium
|
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
55
|
-
attr_reader :args
|
56
|
+
attr_reader :args
|
56
57
|
|
57
58
|
#
|
58
59
|
# Create a new Options instance
|
@@ -86,8 +87,9 @@ module Selenium
|
|
86
87
|
#
|
87
88
|
|
88
89
|
def initialize(**opts)
|
89
|
-
@args =
|
90
|
-
|
90
|
+
@args = (opts.delete(:args) || []).to_set
|
91
|
+
super(**opts)
|
92
|
+
|
91
93
|
@options[:native_events] = true if @options[:native_events].nil?
|
92
94
|
end
|
93
95
|
|
@@ -101,36 +103,11 @@ module Selenium
|
|
101
103
|
@args << arg
|
102
104
|
end
|
103
105
|
|
104
|
-
|
105
|
-
# Add a new option not yet handled by these bindings.
|
106
|
-
#
|
107
|
-
# @example
|
108
|
-
# options = Selenium::WebDriver::IE::Options.new
|
109
|
-
# options.add_option(:foo, 'bar')
|
110
|
-
#
|
111
|
-
# @param [String, Symbol] name Name of the option
|
112
|
-
# @param [Boolean, String, Integer] value Value of the option
|
113
|
-
#
|
114
|
-
|
115
|
-
def add_option(name, value)
|
116
|
-
@options[name] = value
|
117
|
-
end
|
118
|
-
|
119
|
-
#
|
120
|
-
# @api private
|
121
|
-
#
|
122
|
-
|
123
|
-
def as_json(*)
|
124
|
-
opts = {}
|
125
|
-
|
126
|
-
CAPABILITIES.each do |capability_alias, capability_name|
|
127
|
-
capability_value = @options.delete(capability_alias)
|
128
|
-
opts[capability_name] = capability_value unless capability_value.nil?
|
129
|
-
end
|
130
|
-
opts['ie.browserCommandLineSwitches'] = @args.to_a.join(' ') if @args.any?
|
131
|
-
opts.merge!(@options)
|
106
|
+
private
|
132
107
|
|
133
|
-
|
108
|
+
def process_browser_options(browser_options)
|
109
|
+
options = browser_options[KEY]
|
110
|
+
options['ie.browserCommandLineSwitches'] = @args.to_a.join(' ') if @args.any?
|
134
111
|
end
|
135
112
|
end # Options
|
136
113
|
end # IE
|
@@ -20,10 +20,6 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module IE
|
23
|
-
#
|
24
|
-
# @api private
|
25
|
-
#
|
26
|
-
|
27
23
|
class Service < WebDriver::Service
|
28
24
|
DEFAULT_PORT = 5555
|
29
25
|
EXECUTABLE = 'IEDriverServer'
|
@@ -40,11 +36,11 @@ module Selenium
|
|
40
36
|
def extract_service_args(driver_opts)
|
41
37
|
driver_args = super
|
42
38
|
driver_opts = driver_opts.dup
|
43
|
-
driver_args << "--log-level=#{driver_opts
|
44
|
-
driver_args << "--log-file=#{driver_opts
|
45
|
-
driver_args << "--implementation=#{driver_opts
|
46
|
-
driver_args << "--host=#{driver_opts
|
47
|
-
driver_args << "--extract_path=#{driver_opts
|
39
|
+
driver_args << "--log-level=#{driver_opts[:log_level].to_s.upcase}" if driver_opts.key?(:log_level)
|
40
|
+
driver_args << "--log-file=#{driver_opts[:log_file]}" if driver_opts.key?(:log_file)
|
41
|
+
driver_args << "--implementation=#{driver_opts[:implementation].to_s.upcase}" if driver_opts.key?(:implementation)
|
42
|
+
driver_args << "--host=#{driver_opts[:host]}" if driver_opts.key?(:host)
|
43
|
+
driver_args << "--extract_path=#{driver_opts[:extract_path]}" if driver_opts.key?(:extract_path)
|
48
44
|
driver_args << "--silent" if driver_opts[:silent] == true
|
49
45
|
driver_args
|
50
46
|
end
|
@@ -19,13 +19,19 @@
|
|
19
19
|
|
20
20
|
require 'uri'
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
module Selenium
|
23
|
+
module WebDriver
|
24
|
+
module Remote
|
25
|
+
autoload :Bridge, 'selenium/webdriver/remote/bridge'
|
26
|
+
autoload :Driver, 'selenium/webdriver/remote/driver'
|
27
|
+
autoload :Response, 'selenium/webdriver/remote/response'
|
28
|
+
autoload :ServerError, 'selenium/webdriver/remote/server_error'
|
29
|
+
autoload :Capabilities, 'selenium/webdriver/remote/capabilities'
|
30
|
+
autoload :COMMANDS, 'selenium/webdriver/remote/commands'
|
31
|
+
module Http
|
32
|
+
autoload :Common, 'selenium/webdriver/remote/http/common'
|
33
|
+
autoload :Default, 'selenium/webdriver/remote/http/default'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -30,30 +30,17 @@ module Selenium
|
|
30
30
|
|
31
31
|
#
|
32
32
|
# Initializes the bridge with the given server URL
|
33
|
-
# @param [
|
34
|
-
# @
|
35
|
-
# @option opts [Object] :http_client an HTTP client instance that implements the same protocol as Http::Default
|
36
|
-
# @option opts [Capabilities] :desired_capabilities an instance of Remote::Capabilities describing the capabilities you want
|
33
|
+
# @param [String, URI] :url url for the remote server
|
34
|
+
# @param [Object] :http_client an HTTP client instance that implements the same protocol as Http::Default
|
37
35
|
# @api private
|
38
36
|
#
|
39
37
|
|
40
|
-
def initialize(
|
41
|
-
opts = opts.dup
|
42
|
-
|
43
|
-
http_client = opts.delete(:http_client) { Http::Default.new }
|
44
|
-
url = opts.delete(:url) { "http://#{Platform.localhost}:#{PORT}/wd/hub" }
|
45
|
-
opts.delete(:options)
|
46
|
-
|
47
|
-
unless opts.empty?
|
48
|
-
raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
|
49
|
-
end
|
50
|
-
|
38
|
+
def initialize(http_client: nil, url:)
|
51
39
|
uri = url.is_a?(URI) ? url : URI.parse(url)
|
52
|
-
uri.path += '/' unless
|
40
|
+
uri.path += '/' unless uri.path.end_with?('/')
|
53
41
|
|
54
|
-
|
55
|
-
|
56
|
-
@http = http_client
|
42
|
+
@http = http_client || Http::Default.new
|
43
|
+
@http.server_url = uri
|
57
44
|
@file_detector = nil
|
58
45
|
end
|
59
46
|
|
@@ -61,8 +48,8 @@ module Selenium
|
|
61
48
|
# Creates session.
|
62
49
|
#
|
63
50
|
|
64
|
-
def create_session(
|
65
|
-
response = execute(:new_session, {},
|
51
|
+
def create_session(capabilities)
|
52
|
+
response = execute(:new_session, {}, {capabilities: {firstMatch: [capabilities]}})
|
66
53
|
|
67
54
|
@session_id = response['sessionId']
|
68
55
|
capabilities = response['capabilities']
|
@@ -525,23 +512,28 @@ module Selenium
|
|
525
512
|
alias_method :switch_to_active_element, :active_element
|
526
513
|
|
527
514
|
def find_element_by(how, what, parent = nil)
|
528
|
-
how, what =
|
515
|
+
how, what = convert_locator(how, what)
|
516
|
+
|
517
|
+
return execute_atom(:findElements, Support::RelativeLocator.new(what).as_json).first if how == 'relative'
|
529
518
|
|
530
519
|
id = if parent
|
531
|
-
execute :find_child_element, {id: parent}, {using: how, value: what}
|
520
|
+
execute :find_child_element, {id: parent}, {using: how, value: what.to_s}
|
532
521
|
else
|
533
|
-
execute :find_element, {}, {using: how, value: what}
|
522
|
+
execute :find_element, {}, {using: how, value: what.to_s}
|
534
523
|
end
|
524
|
+
|
535
525
|
Element.new self, element_id_from(id)
|
536
526
|
end
|
537
527
|
|
538
528
|
def find_elements_by(how, what, parent = nil)
|
539
|
-
how, what =
|
529
|
+
how, what = convert_locator(how, what)
|
530
|
+
|
531
|
+
return execute_atom :findElements, Support::RelativeLocator.new(what).as_json if how == 'relative'
|
540
532
|
|
541
533
|
ids = if parent
|
542
|
-
execute :find_child_elements, {id: parent}, {using: how, value: what}
|
534
|
+
execute :find_child_elements, {id: parent}, {using: how, value: what.to_s}
|
543
535
|
else
|
544
|
-
execute :find_elements, {}, {using: how, value: what}
|
536
|
+
execute :find_elements, {}, {using: how, value: what.to_s}
|
545
537
|
end
|
546
538
|
|
547
539
|
ids.map { |id| Element.new self, element_id_from(id) }
|
@@ -579,16 +571,6 @@ module Selenium
|
|
579
571
|
COMMANDS[command]
|
580
572
|
end
|
581
573
|
|
582
|
-
def merged_capabilities(capabilities, options = nil)
|
583
|
-
capabilities.merge!(options.as_json) if options
|
584
|
-
|
585
|
-
{
|
586
|
-
capabilities: {
|
587
|
-
firstMatch: [capabilities]
|
588
|
-
}
|
589
|
-
}
|
590
|
-
end
|
591
|
-
|
592
574
|
def unwrap_script_result(arg)
|
593
575
|
case arg
|
594
576
|
when Array
|
@@ -607,20 +589,30 @@ module Selenium
|
|
607
589
|
id['ELEMENT'] || id['element-6066-11e4-a52e-4f735466cecf']
|
608
590
|
end
|
609
591
|
|
610
|
-
def
|
592
|
+
def convert_locator(how, what)
|
593
|
+
how = SearchContext::FINDERS[how.to_sym] || how
|
594
|
+
|
611
595
|
case how
|
612
596
|
when 'class name'
|
613
597
|
how = 'css selector'
|
614
|
-
what = ".#{escape_css(what)}"
|
598
|
+
what = ".#{escape_css(what.to_s)}"
|
615
599
|
when 'id'
|
616
600
|
how = 'css selector'
|
617
|
-
what = "##{escape_css(what)}"
|
601
|
+
what = "##{escape_css(what.to_s)}"
|
618
602
|
when 'name'
|
619
603
|
how = 'css selector'
|
620
|
-
what = "*[name='#{escape_css(what)}']"
|
604
|
+
what = "*[name='#{escape_css(what.to_s)}']"
|
621
605
|
when 'tag name'
|
622
606
|
how = 'css selector'
|
623
607
|
end
|
608
|
+
|
609
|
+
if what.is_a?(Hash)
|
610
|
+
what = what.each_with_object({}) do |(h, w), hash|
|
611
|
+
h, w = convert_locator(h.to_s, w)
|
612
|
+
hash[h] = w
|
613
|
+
end
|
614
|
+
end
|
615
|
+
|
624
616
|
[how, what]
|
625
617
|
end
|
626
618
|
|
@@ -631,7 +623,7 @@ module Selenium
|
|
631
623
|
# @see https://mathiasbynens.be/notes/css-escapes
|
632
624
|
def escape_css(string)
|
633
625
|
string = string.gsub(ESCAPE_CSS_REGEXP) { |match| "\\#{match}" }
|
634
|
-
string = "\\#{UNICODE_CODE_POINT + Integer(string[0])} #{string[1..-1]}" if
|
626
|
+
string = "\\#{UNICODE_CODE_POINT + Integer(string[0])} #{string[1..-1]}" if string[0]&.match?(/[[:digit:]]/)
|
635
627
|
|
636
628
|
string
|
637
629
|
end
|
@@ -82,12 +82,22 @@ module Selenium
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def edge(opts = {})
|
85
|
+
edge_html(opts)
|
86
|
+
end
|
87
|
+
|
88
|
+
def edge_html(opts = {})
|
85
89
|
new({
|
86
90
|
browser_name: 'MicrosoftEdge',
|
87
91
|
platform_name: :windows
|
88
92
|
}.merge(opts))
|
89
93
|
end
|
90
94
|
|
95
|
+
def edge_chrome(opts = {})
|
96
|
+
new({
|
97
|
+
browser_name: 'MicrosoftEdge'
|
98
|
+
}.merge(opts))
|
99
|
+
end
|
100
|
+
|
91
101
|
def firefox(opts = {})
|
92
102
|
opts[:browser_version] = opts.delete(:version) if opts.key?(:version)
|
93
103
|
opts[:platform_name] = opts.delete(:platform) if opts.key?(:platform)
|
@@ -95,6 +105,7 @@ module Selenium
|
|
95
105
|
opts[:timeouts]['implicit'] = opts.delete(:implicit_timeout) if opts.key?(:implicit_timeout)
|
96
106
|
opts[:timeouts]['pageLoad'] = opts.delete(:page_load_timeout) if opts.key?(:page_load_timeout)
|
97
107
|
opts[:timeouts]['script'] = opts.delete(:script_timeout) if opts.key?(:script_timeout)
|
108
|
+
opts.delete(:timeouts) if opts[:timeouts].empty?
|
98
109
|
new({browser_name: 'firefox'}.merge(opts))
|
99
110
|
end
|
100
111
|
|
@@ -135,12 +146,7 @@ module Selenium
|
|
135
146
|
caps.accept_insecure_certs = data.delete('acceptInsecureCerts') if data.key?('acceptInsecureCerts')
|
136
147
|
caps.page_load_strategy = data.delete('pageLoadStrategy') if data.key?('pageLoadStrategy')
|
137
148
|
|
138
|
-
|
139
|
-
timeouts = data.delete('timeouts')
|
140
|
-
caps.implicit_timeout = timeouts['implicit'] if timeouts
|
141
|
-
caps.page_load_timeout = timeouts['pageLoad'] if timeouts
|
142
|
-
caps.script_timeout = timeouts['script'] if timeouts
|
143
|
-
end
|
149
|
+
process_timeouts(caps, data.delete('timeouts'))
|
144
150
|
|
145
151
|
if data.key?('proxy')
|
146
152
|
proxy = data.delete('proxy')
|
@@ -155,6 +161,16 @@ module Selenium
|
|
155
161
|
|
156
162
|
caps
|
157
163
|
end
|
164
|
+
|
165
|
+
private
|
166
|
+
|
167
|
+
def process_timeouts(caps, timeouts)
|
168
|
+
return if timeouts.nil?
|
169
|
+
|
170
|
+
caps.implicit_timeout = timeouts['implicit']
|
171
|
+
caps.page_load_timeout = timeouts['pageLoad']
|
172
|
+
caps.script_timeout = timeouts['script']
|
173
|
+
end
|
158
174
|
end
|
159
175
|
|
160
176
|
#
|
@@ -34,24 +34,18 @@ module Selenium
|
|
34
34
|
include DriverExtensions::HasRemoteStatus
|
35
35
|
include DriverExtensions::HasWebStorage
|
36
36
|
|
37
|
-
def initialize(
|
38
|
-
|
39
|
-
desired_capabilities = opts.delete(:desired_capabilities) { Capabilities.new }
|
40
|
-
|
37
|
+
def initialize(bridge: nil, listener: nil, **opts)
|
38
|
+
desired_capabilities = opts[:desired_capabilities]
|
41
39
|
if desired_capabilities.is_a?(Symbol)
|
42
|
-
unless Capabilities.respond_to?(desired_capabilities)
|
40
|
+
unless Remote::Capabilities.respond_to?(desired_capabilities)
|
43
41
|
raise Error::WebDriverError, "invalid desired capability: #{desired_capabilities.inspect}"
|
44
42
|
end
|
45
43
|
|
46
|
-
desired_capabilities = Capabilities.__send__(desired_capabilities)
|
44
|
+
opts[:desired_capabilities] = Remote::Capabilities.__send__(desired_capabilities)
|
47
45
|
end
|
48
|
-
|
49
|
-
|
50
|
-
@bridge.create_session(desired_capabilities, opts.delete(:options))
|
51
|
-
|
52
|
-
super(@bridge, listener: listener)
|
46
|
+
opts[:url] ||= "http://#{Platform.localhost}:4444/wd/hub"
|
47
|
+
super
|
53
48
|
end
|
54
|
-
|
55
49
|
end # Driver
|
56
50
|
end # Remote
|
57
51
|
end # WebDriver
|