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.
Files changed (137) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGES +139 -1
  3. data/LICENSE +1 -1
  4. data/lib/selenium/server.rb +3 -3
  5. data/lib/selenium/webdriver.rb +11 -7
  6. data/lib/selenium/webdriver/atoms/findElements.js +122 -0
  7. data/lib/selenium/webdriver/atoms/getAttribute.js +84 -7
  8. data/lib/selenium/webdriver/atoms/isDisplayed.js +75 -77
  9. data/lib/selenium/webdriver/chrome.rb +10 -9
  10. data/lib/selenium/webdriver/chrome/bridge.rb +20 -4
  11. data/lib/selenium/webdriver/chrome/driver.rb +3 -52
  12. data/lib/selenium/webdriver/chrome/options.rb +97 -57
  13. data/lib/selenium/webdriver/chrome/profile.rb +2 -2
  14. data/lib/selenium/webdriver/chrome/service.rb +0 -4
  15. data/lib/selenium/webdriver/common.rb +3 -0
  16. data/lib/selenium/webdriver/common/driver.rb +76 -17
  17. data/lib/selenium/webdriver/common/driver_extensions/{has_touch_screen.rb → has_devtools.rb} +10 -8
  18. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +2 -1
  19. data/lib/selenium/webdriver/common/logger.rb +48 -16
  20. data/lib/selenium/webdriver/common/manager.rb +5 -0
  21. data/lib/selenium/webdriver/common/options.rb +60 -121
  22. data/lib/selenium/webdriver/common/platform.rb +3 -0
  23. data/lib/selenium/webdriver/common/port_prober.rb +4 -6
  24. data/lib/selenium/webdriver/common/profile_helper.rb +10 -2
  25. data/lib/selenium/webdriver/common/proxy.rb +0 -0
  26. data/lib/selenium/webdriver/common/search_context.rb +3 -2
  27. data/lib/selenium/webdriver/common/service.rb +30 -113
  28. data/lib/selenium/webdriver/common/service_manager.rb +151 -0
  29. data/lib/selenium/webdriver/common/socket_lock.rb +2 -2
  30. data/lib/selenium/webdriver/common/wait.rb +1 -1
  31. data/lib/selenium/webdriver/devtools.rb +118 -0
  32. data/lib/selenium/webdriver/devtools/accessibility.rb +62 -0
  33. data/lib/selenium/webdriver/devtools/animation.rb +98 -0
  34. data/lib/selenium/webdriver/devtools/application_cache.rb +64 -0
  35. data/lib/selenium/webdriver/devtools/audits.rb +61 -0
  36. data/lib/selenium/webdriver/devtools/background_service.rb +67 -0
  37. data/lib/selenium/webdriver/devtools/browser.rb +123 -0
  38. data/lib/selenium/webdriver/devtools/cache_storage.rb +73 -0
  39. data/lib/selenium/webdriver/devtools/cast.rb +70 -0
  40. data/lib/selenium/webdriver/devtools/console.rb +57 -0
  41. data/lib/selenium/webdriver/devtools/css.rb +165 -0
  42. data/lib/selenium/webdriver/devtools/database.rb +64 -0
  43. data/lib/selenium/webdriver/devtools/debugger.rb +229 -0
  44. data/lib/selenium/webdriver/devtools/device_orientation.rb +53 -0
  45. data/lib/selenium/webdriver/devtools/dom.rb +320 -0
  46. data/lib/selenium/webdriver/devtools/domdebugger.rb +93 -0
  47. data/lib/selenium/webdriver/devtools/domsnapshot.rb +65 -0
  48. data/lib/selenium/webdriver/devtools/domstorage.rb +79 -0
  49. data/lib/selenium/webdriver/devtools/emulation.rb +180 -0
  50. data/lib/selenium/webdriver/devtools/fetch.rb +97 -0
  51. data/lib/selenium/webdriver/devtools/headless_experimental.rb +61 -0
  52. data/lib/selenium/webdriver/devtools/heap_profiler.rb +107 -0
  53. data/lib/selenium/webdriver/devtools/indexed_db.rb +100 -0
  54. data/lib/selenium/webdriver/devtools/input.rb +140 -0
  55. data/lib/selenium/webdriver/devtools/inspector.rb +55 -0
  56. data/lib/selenium/webdriver/devtools/io.rb +59 -0
  57. data/lib/selenium/webdriver/devtools/layer_tree.rb +95 -0
  58. data/lib/selenium/webdriver/devtools/log.rb +66 -0
  59. data/lib/selenium/webdriver/devtools/media.rb +57 -0
  60. data/lib/selenium/webdriver/devtools/memory.rb +86 -0
  61. data/lib/selenium/webdriver/devtools/network.rb +228 -0
  62. data/lib/selenium/webdriver/devtools/overlay.rb +157 -0
  63. data/lib/selenium/webdriver/devtools/page.rb +374 -0
  64. data/lib/selenium/webdriver/devtools/performance.rb +63 -0
  65. data/lib/selenium/webdriver/devtools/profiler.rb +111 -0
  66. data/lib/selenium/webdriver/devtools/runtime.rb +193 -0
  67. data/lib/selenium/webdriver/devtools/schema.rb +46 -0
  68. data/lib/selenium/webdriver/devtools/security.rb +71 -0
  69. data/lib/selenium/webdriver/devtools/service_worker.rb +116 -0
  70. data/lib/selenium/webdriver/devtools/storage.rb +95 -0
  71. data/lib/selenium/webdriver/devtools/system_info.rb +50 -0
  72. data/lib/selenium/webdriver/devtools/target.rb +141 -0
  73. data/lib/selenium/webdriver/devtools/tethering.rb +55 -0
  74. data/lib/selenium/webdriver/devtools/tracing.rb +76 -0
  75. data/lib/selenium/webdriver/devtools/web_audio.rb +70 -0
  76. data/lib/selenium/webdriver/devtools/web_authn.rb +94 -0
  77. data/lib/selenium/webdriver/edge.rb +29 -9
  78. data/lib/selenium/webdriver/{firefox/util.rb → edge_chrome/bridge.rb} +11 -20
  79. data/lib/selenium/webdriver/{common/w3c_options.rb → edge_chrome/driver.rb} +14 -17
  80. data/lib/selenium/webdriver/edge_chrome/options.rb +36 -0
  81. data/lib/selenium/webdriver/edge_chrome/profile.rb +33 -0
  82. data/lib/selenium/webdriver/edge_chrome/service.rb +36 -0
  83. data/lib/selenium/webdriver/{common/w3c_manager.rb → edge_html/driver.rb} +11 -17
  84. data/lib/selenium/webdriver/{edge → edge_html}/options.rb +26 -22
  85. data/lib/selenium/webdriver/{edge → edge_html}/service.rb +2 -6
  86. data/lib/selenium/webdriver/firefox.rb +18 -15
  87. data/lib/selenium/webdriver/firefox/bridge.rb +1 -1
  88. data/lib/selenium/webdriver/firefox/driver.rb +2 -30
  89. data/lib/selenium/webdriver/firefox/extension.rb +8 -0
  90. data/lib/selenium/webdriver/firefox/options.rb +47 -52
  91. data/lib/selenium/webdriver/firefox/profile.rb +7 -78
  92. data/lib/selenium/webdriver/firefox/service.rb +0 -4
  93. data/lib/selenium/webdriver/ie.rb +8 -7
  94. data/lib/selenium/webdriver/ie/driver.rb +0 -32
  95. data/lib/selenium/webdriver/ie/options.rb +10 -33
  96. data/lib/selenium/webdriver/ie/service.rb +5 -9
  97. data/lib/selenium/webdriver/remote.rb +16 -10
  98. data/lib/selenium/webdriver/remote/bridge.rb +34 -42
  99. data/lib/selenium/webdriver/remote/capabilities.rb +22 -6
  100. data/lib/selenium/webdriver/remote/driver.rb +6 -12
  101. data/lib/selenium/webdriver/remote/http/default.rb +9 -4
  102. data/lib/selenium/webdriver/remote/http/persistent.rb +5 -6
  103. data/lib/selenium/webdriver/safari.rb +9 -8
  104. data/lib/selenium/webdriver/safari/bridge.rb +4 -4
  105. data/lib/selenium/webdriver/safari/driver.rb +3 -29
  106. data/lib/selenium/webdriver/safari/options.rb +18 -19
  107. data/lib/selenium/webdriver/safari/service.rb +0 -4
  108. data/lib/selenium/webdriver/support.rb +1 -0
  109. data/lib/selenium/webdriver/support/cdp_client_generator.rb +77 -0
  110. data/lib/selenium/webdriver/support/color.rb +2 -2
  111. data/lib/selenium/webdriver/support/event_firing_bridge.rb +1 -1
  112. data/lib/selenium/webdriver/support/relative_locator.rb +51 -0
  113. data/lib/selenium/webdriver/version.rb +1 -1
  114. data/selenium-webdriver.gemspec +5 -4
  115. metadata +81 -42
  116. data/lib/selenium/webdriver/common/bridge_helper.rb +0 -82
  117. data/lib/selenium/webdriver/common/keyboard.rb +0 -70
  118. data/lib/selenium/webdriver/common/mouse.rb +0 -89
  119. data/lib/selenium/webdriver/common/touch_action_builder.rb +0 -78
  120. data/lib/selenium/webdriver/common/touch_screen.rb +0 -123
  121. data/lib/selenium/webdriver/common/w3c_action_builder.rb +0 -212
  122. data/lib/selenium/webdriver/edge/bridge.rb +0 -76
  123. data/lib/selenium/webdriver/edge/driver.rb +0 -70
  124. data/lib/selenium/webdriver/firefox/binary.rb +0 -110
  125. data/lib/selenium/webdriver/firefox/extension/prefs.json +0 -69
  126. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  127. data/lib/selenium/webdriver/firefox/launcher.rb +0 -111
  128. data/lib/selenium/webdriver/firefox/legacy/driver.rb +0 -83
  129. data/lib/selenium/webdriver/firefox/marionette/bridge.rb +0 -49
  130. data/lib/selenium/webdriver/firefox/marionette/driver.rb +0 -90
  131. data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
  132. data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
  133. data/lib/selenium/webdriver/remote/oss/bridge.rb +0 -594
  134. data/lib/selenium/webdriver/remote/oss/commands.rb +0 -223
  135. data/lib/selenium/webdriver/remote/w3c/bridge.rb +0 -605
  136. data/lib/selenium/webdriver/remote/w3c/capabilities.rb +0 -310
  137. data/lib/selenium/webdriver/remote/w3c/commands.rb +0 -157
@@ -1,76 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Licensed to the Software Freedom Conservancy (SFC) under one
4
- # or more contributor license agreements. See the NOTICE file
5
- # distributed with this work for additional information
6
- # regarding copyright ownership. The SFC licenses this file
7
- # to you under the Apache License, Version 2.0 (the
8
- # "License"); you may not use this file except in compliance
9
- # with the License. You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing,
14
- # software distributed under the License is distributed on an
15
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- # KIND, either express or implied. See the License for the
17
- # specific language governing permissions and limitations
18
- # under the License.
19
-
20
- module Selenium
21
- module WebDriver
22
- module Edge
23
- module Bridge
24
-
25
- def commands(command)
26
- unsupported = %i[execute_script execute_async_script submit_element double_click
27
- mouse_down mouse_up mouse_move_to click
28
- send_keys_to_active_element get_window_handles get_current_window_handle
29
- get_window_size set_window_size get_window_position set_window_position
30
- maximize_window get_alert_text accept_alert dismiss_alert]
31
- if unsupported.include? command
32
- Remote::OSS::Bridge::COMMANDS[command]
33
- else
34
- super
35
- end
36
- end
37
-
38
- def send_keys_to_active_element(key)
39
- execute :send_keys_to_active_element, {}, {value: key}
40
- end
41
-
42
- def window_handle
43
- execute :get_current_window_handle
44
- end
45
-
46
- def window_size(handle = :current)
47
- data = execute :get_window_size, window_handle: handle
48
-
49
- Dimension.new data['width'], data['height']
50
- end
51
-
52
- def resize_window(width, height, handle = :current)
53
- execute :set_window_size, {window_handle: handle},
54
- {width: width,
55
- height: height}
56
- end
57
-
58
- def window_position(handle = :current)
59
- data = execute :get_window_position, window_handle: handle
60
-
61
- Point.new data['x'], data['y']
62
- end
63
-
64
- def reposition_window(x, y, handle = :current)
65
- execute :set_window_position, {window_handle: handle},
66
- {x: x, y: y}
67
- end
68
-
69
- def maximize_window(handle = :current)
70
- execute :maximize_window, window_handle: handle
71
- end
72
-
73
- end # Bridge
74
- end # Edge
75
- end # WebDriver
76
- end # Selenium
@@ -1,70 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Licensed to the Software Freedom Conservancy (SFC) under one
4
- # or more contributor license agreements. See the NOTICE file
5
- # distributed with this work for additional information
6
- # regarding copyright ownership. The SFC licenses this file
7
- # to you under the Apache License, Version 2.0 (the
8
- # "License"); you may not use this file except in compliance
9
- # with the License. You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing,
14
- # software distributed under the License is distributed on an
15
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- # KIND, either express or implied. See the License for the
17
- # specific language governing permissions and limitations
18
- # under the License.
19
-
20
- module Selenium
21
- module WebDriver
22
- module Edge
23
-
24
- #
25
- # Driver implementation for Microsoft Edge.
26
- # @api private
27
- #
28
-
29
- class Driver < WebDriver::Driver
30
- include DriverExtensions::HasWebStorage
31
- include DriverExtensions::TakesScreenshot
32
-
33
- def initialize(opts = {})
34
- opts[:desired_capabilities] = create_capabilities(opts)
35
-
36
- opts[:url] ||= service_url(opts)
37
-
38
- listener = opts.delete(:listener)
39
- desired_capabilities = opts.delete(:desired_capabilities)
40
-
41
- @bridge = Remote::Bridge.new(opts)
42
- @bridge.create_session(desired_capabilities)
43
-
44
- super(@bridge, listener: listener)
45
- end
46
-
47
- def browser
48
- :edge
49
- end
50
-
51
- def quit
52
- super
53
- ensure
54
- @service&.stop
55
- end
56
-
57
- private
58
-
59
- def create_capabilities(opts)
60
- caps = opts.delete(:desired_capabilities) { Remote::Capabilities.edge }
61
- options = opts.delete(:options) { Options.new }
62
- options = options.as_json
63
- caps.merge!(options) unless options.empty?
64
-
65
- caps
66
- end
67
- end # Driver
68
- end # Edge
69
- end # WebDriver
70
- end # Selenium
@@ -1,110 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Licensed to the Software Freedom Conservancy (SFC) under one
4
- # or more contributor license agreements. See the NOTICE file
5
- # distributed with this work for additional information
6
- # regarding copyright ownership. The SFC licenses this file
7
- # to you under the Apache License, Version 2.0 (the
8
- # "License"); you may not use this file except in compliance
9
- # with the License. You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing,
14
- # software distributed under the License is distributed on an
15
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- # KIND, either express or implied. See the License for the
17
- # specific language governing permissions and limitations
18
- # under the License.
19
-
20
- module Selenium
21
- module WebDriver
22
- module Firefox
23
- # @api private
24
- class Binary
25
- class << self
26
- #
27
- # @api private
28
- #
29
- # @see Firefox.path=
30
- #
31
-
32
- def path=(path)
33
- Platform.assert_executable(path)
34
- @path = path
35
- end
36
-
37
- def reset_path!
38
- @path = nil
39
- end
40
-
41
- def path
42
- @path ||= case Platform.os
43
- when :macosx
44
- macosx_path
45
- when :windows
46
- windows_path
47
- when :linux, :unix
48
- Platform.find_binary('firefox3', 'firefox2', 'firefox') || '/usr/bin/firefox'
49
- else
50
- raise Error::WebDriverError, "unknown platform: #{Platform.os}"
51
- end
52
-
53
- @path = Platform.cygwin_path(@path, windows: true) if Platform.cygwin?
54
-
55
- unless File.file?(@path.to_s)
56
- error = "Could not find Firefox binary (os=#{Platform.os}). "
57
- error << "Make sure Firefox is installed or set the path manually with #{self}.path="
58
- raise Error::WebDriverError, error
59
- end
60
-
61
- @path
62
- end
63
-
64
- def version
65
- @version = case Platform.os
66
- when :macosx
67
- `#{path} -v`.strip[/[^\s]*$/][/^\d+/].to_i
68
- when :windows
69
- `\"#{path}\" -v | more`.strip[/[^\s]*$/][/^\d+/].to_i
70
- when :linux
71
- `#{path} -v`.strip[/[^\s]*$/][/^\d+/].to_i
72
- else
73
- 0
74
- end
75
- end
76
-
77
- private
78
-
79
- def windows_path
80
- windows_registry_path ||
81
- Platform.find_in_program_files('\\Mozilla Firefox\\firefox.exe') ||
82
- Platform.find_binary('firefox')
83
- end
84
-
85
- def macosx_path
86
- path = '/Applications/Firefox.app/Contents/MacOS/firefox-bin'
87
- path = File.expand_path('~/Applications/Firefox.app/Contents/MacOS/firefox-bin') unless File.exist?(path)
88
- path = Platform.find_binary('firefox-bin') unless File.exist?(path)
89
-
90
- path
91
- end
92
-
93
- def windows_registry_path
94
- require 'win32/registry'
95
-
96
- lm = Win32::Registry::HKEY_LOCAL_MACHINE
97
- lm.open('SOFTWARE\\Mozilla\\Mozilla Firefox') do |reg|
98
- main = lm.open("SOFTWARE\\Mozilla\\Mozilla Firefox\\#{reg.keys[0]}\\Main")
99
- entry = main.find { |key, _type, _data| /pathtoexe/i.match? key }
100
- return entry.last if entry
101
- end
102
- rescue LoadError
103
- # older JRuby or IronRuby does not have win32/registry
104
- rescue Win32::Registry::Error
105
- end
106
- end # class << self
107
- end # Binary
108
- end # Firefox
109
- end # WebDriver
110
- end # Selenium
@@ -1,69 +0,0 @@
1
- {
2
- "frozen": {
3
- "app.update.auto": false,
4
- "app.update.enabled": false,
5
- "browser.displayedE10SNotice": 4,
6
- "browser.download.manager.showWhenStarting": false,
7
- "browser.EULA.override": true,
8
- "browser.EULA.3.accepted": true,
9
- "browser.link.open_external": 2,
10
- "browser.link.open_newwindow": 2,
11
- "browser.offline": false,
12
- "browser.reader.detectedFirstArticle": true,
13
- "browser.safebrowsing.enabled": false,
14
- "browser.safebrowsing.malware.enabled": false,
15
- "browser.search.update": false,
16
- "browser.selfsupport.url" : "",
17
- "browser.sessionstore.resume_from_crash": false,
18
- "browser.shell.checkDefaultBrowser": false,
19
- "browser.tabs.warnOnClose": false,
20
- "browser.tabs.warnOnOpen": false,
21
- "datareporting.healthreport.service.enabled": false,
22
- "datareporting.healthreport.uploadEnabled": false,
23
- "datareporting.healthreport.service.firstRun": false,
24
- "datareporting.healthreport.logging.consoleEnabled": false,
25
- "datareporting.policy.dataSubmissionEnabled": false,
26
- "datareporting.policy.dataSubmissionPolicyAccepted": false,
27
- "devtools.errorconsole.enabled": true,
28
- "dom.disable_open_during_load": false,
29
- "extensions.autoDisableScopes": 10,
30
- "extensions.blocklist.enabled": false,
31
- "extensions.checkCompatibility.nightly": false,
32
- "extensions.update.enabled": false,
33
- "extensions.update.notifyUser": false,
34
- "javascript.enabled": true,
35
- "network.manage-offline-status": false,
36
- "network.http.phishy-userpass-length": 255,
37
- "offline-apps.allow_by_default": true,
38
- "prompts.tab_modal.enabled": false,
39
- "security.fileuri.origin_policy": 3,
40
- "security.fileuri.strict_origin_policy": false,
41
- "signon.rememberSignons": false,
42
- "toolkit.networkmanager.disable": true,
43
- "toolkit.telemetry.prompted": 2,
44
- "toolkit.telemetry.enabled": false,
45
- "toolkit.telemetry.rejected": true,
46
- "xpinstall.signatures.required": false,
47
- "xpinstall.whitelist.required": false
48
- },
49
- "mutable": {
50
- "browser.dom.window.dump.enabled": true,
51
- "browser.laterrun.enabled": false,
52
- "browser.newtab.url": "about:blank",
53
- "browser.newtabpage.enabled": false,
54
- "browser.startup.page": 0,
55
- "browser.startup.homepage": "about:blank",
56
- "browser.startup.homepage_override.mstone": "ignore",
57
- "browser.usedOnWindows10.introURL": "about:blank",
58
- "dom.max_chrome_script_run_time": 30,
59
- "dom.max_script_run_time": 30,
60
- "dom.report_all_js_exceptions": true,
61
- "javascript.options.showInConsole": true,
62
- "network.captive-portal-service.enabled": false,
63
- "security.csp.enable": false,
64
- "startup.homepage_welcome_url": "about:blank",
65
- "startup.homepage_welcome_url.additional": "about:blank",
66
- "webdriver_accept_untrusted_certs": true,
67
- "webdriver_assume_untrusted_issuer": true
68
- }
69
- }
@@ -1,111 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Licensed to the Software Freedom Conservancy (SFC) under one
4
- # or more contributor license agreements. See the NOTICE file
5
- # distributed with this work for additional information
6
- # regarding copyright ownership. The SFC licenses this file
7
- # to you under the Apache License, Version 2.0 (the
8
- # "License"); you may not use this file except in compliance
9
- # with the License. You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing,
14
- # software distributed under the License is distributed on an
15
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- # KIND, either express or implied. See the License for the
17
- # specific language governing permissions and limitations
18
- # under the License.
19
-
20
- module Selenium
21
- module WebDriver
22
- module Firefox
23
- # @api private
24
- class Launcher
25
- SOCKET_LOCK_TIMEOUT = 45
26
- STABLE_CONNECTION_TIMEOUT = 60
27
-
28
- def initialize(binary, port, profile = nil)
29
- @binary = binary
30
- @port = Integer(port)
31
-
32
- raise Error::WebDriverError, "invalid port: #{@port}" if @port < 1
33
-
34
- if profile.is_a? Profile
35
- @profile = profile
36
- else
37
- @profile_name = profile
38
- @profile = nil
39
- end
40
-
41
- @host = '127.0.0.1'
42
- end
43
-
44
- def url
45
- "http://#{@host}:#{@port}/hub"
46
- end
47
-
48
- def launch
49
- socket_lock.locked do
50
- find_free_port
51
- create_profile
52
- start
53
- connect_until_stable
54
- end
55
-
56
- self
57
- end
58
-
59
- def quit
60
- @binary.quit
61
- FileReaper.reap(@profile_dir) if @profile_dir
62
- end
63
-
64
- def find_free_port
65
- @port = PortProber.above @port
66
- end
67
-
68
- def create_profile
69
- fetch_profile unless @profile
70
-
71
- @profile.add_webdriver_extension
72
- @profile.port = @port
73
-
74
- @profile_dir = @profile.layout_on_disk
75
- FileReaper << @profile_dir
76
- end
77
-
78
- def start
79
- assert_profile
80
- @binary.start_with @profile, @profile_dir, '-foreground'
81
- end
82
-
83
- def connect_until_stable
84
- poller = SocketPoller.new(@host, @port, STABLE_CONNECTION_TIMEOUT)
85
-
86
- return if poller.connected?
87
-
88
- @binary.quit
89
- error = "unable to obtain stable firefox connection in #{STABLE_CONNECTION_TIMEOUT} seconds (#{@host}:#{@port})"
90
- raise Error::WebDriverError, error
91
- end
92
-
93
- def fetch_profile
94
- @profile = if @profile_name
95
- Profile.from_name @profile_name
96
- else
97
- Profile.new
98
- end
99
- end
100
-
101
- def assert_profile
102
- raise Error::WebDriverError, 'must create_profile first' unless @profile && @profile_dir
103
- end
104
-
105
- def socket_lock
106
- @socket_lock ||= SocketLock.new(@port - 1, SOCKET_LOCK_TIMEOUT)
107
- end
108
- end # Launcher
109
- end # Firefox
110
- end # WebDriver
111
- end # Selenium
@@ -1,83 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Licensed to the Software Freedom Conservancy (SFC) under one
4
- # or more contributor license agreements. See the NOTICE file
5
- # distributed with this work for additional information
6
- # regarding copyright ownership. The SFC licenses this file
7
- # to you under the Apache License, Version 2.0 (the
8
- # "License"); you may not use this file except in compliance
9
- # with the License. You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing,
14
- # software distributed under the License is distributed on an
15
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- # KIND, either express or implied. See the License for the
17
- # specific language governing permissions and limitations
18
- # under the License.
19
-
20
- module Selenium
21
- module WebDriver
22
- module Firefox
23
- module Legacy
24
-
25
- #
26
- # Driver implementation for Firefox using legacy extension.
27
- # @api private
28
- #
29
-
30
- class Driver < WebDriver::Driver
31
- include DriverExtensions::TakesScreenshot
32
-
33
- def initialize(opts = {}) # rubocop:disable Metrics/AbcSize
34
- WebDriver.logger.deprecate 'Selenium support for legacy Firefox', 'Firefox via marionette'
35
-
36
- opts[:desired_capabilities] ||= Remote::Capabilities.firefox_legacy
37
-
38
- if opts.key? :proxy
39
- WebDriver.logger.deprecate ':proxy', "Selenium::WebDriver::Remote::Capabilities.firefox(proxy: #{opts[:proxy]})"
40
- opts[:desired_capabilities].proxy = opts.delete(:proxy)
41
- end
42
-
43
- unless opts.key?(:url)
44
- port = opts.delete(:port) || DEFAULT_PORT
45
- profile = opts.delete(:profile)
46
-
47
- Binary.path = opts[:desired_capabilities][:firefox_binary] if opts[:desired_capabilities][:firefox_binary]
48
- @launcher = Launcher.new Binary.new, port, profile
49
- @launcher.launch
50
- opts[:url] = @launcher.url
51
- end
52
-
53
- listener = opts.delete(:listener)
54
- WebDriver.logger.info 'Skipping handshake as we know it is OSS.'
55
- desired_capabilities = opts.delete(:desired_capabilities)
56
- bridge = Remote::Bridge.new(opts)
57
- capabilities = bridge.create_session(desired_capabilities)
58
- @bridge = Remote::OSS::Bridge.new(capabilities, bridge.session_id, opts)
59
-
60
- begin
61
- super(@bridge, listener: listener)
62
- rescue
63
- @launcher&.quit
64
- raise
65
- end
66
- end
67
-
68
- def browser
69
- :firefox
70
- end
71
-
72
- def quit
73
- super
74
- nil
75
- ensure
76
- @launcher.quit
77
- end
78
-
79
- end # Driver
80
- end # Legacy
81
- end # Firefox
82
- end # WebDriver
83
- end # Selenium