selenium-webdriver 2.53.4 → 3.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGES +363 -10
- data/LICENSE +1 -1
- data/README.md +2 -3
- data/lib/selenium-webdriver.rb +0 -2
- data/lib/selenium/server.rb +69 -70
- data/lib/selenium/webdriver.rb +32 -23
- data/lib/selenium/webdriver/atoms.rb +18 -0
- data/lib/selenium/webdriver/atoms/getAttribute.js +8 -0
- data/lib/selenium/webdriver/chrome.rb +8 -6
- data/lib/selenium/webdriver/chrome/driver.rb +112 -0
- data/lib/selenium/webdriver/chrome/options.rb +168 -0
- data/lib/selenium/webdriver/chrome/profile.rb +17 -17
- data/lib/selenium/webdriver/chrome/service.rb +22 -89
- data/lib/selenium/webdriver/common.rb +13 -6
- data/lib/selenium/webdriver/common/action_builder.rb +49 -57
- data/lib/selenium/webdriver/common/alert.rb +5 -15
- data/lib/selenium/webdriver/common/bridge_helper.rb +10 -17
- data/lib/selenium/webdriver/common/driver.rb +53 -68
- data/lib/selenium/webdriver/common/driver_extensions/{has_input_devices.rb → has_addons.rb} +13 -23
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +4 -8
- data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +4 -7
- data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +0 -4
- data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +0 -4
- data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +1 -5
- data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +0 -5
- data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +4 -9
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +7 -7
- data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +2 -7
- data/lib/selenium/webdriver/common/element.rb +57 -39
- data/lib/selenium/webdriver/common/error.rb +204 -106
- data/lib/selenium/webdriver/common/file_reaper.rb +3 -11
- data/lib/selenium/webdriver/common/html5/local_storage.rb +6 -10
- data/lib/selenium/webdriver/common/html5/session_storage.rb +6 -10
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +7 -18
- data/lib/selenium/webdriver/{safari/options.rb → common/interactions/input_device.rb} +20 -31
- data/lib/selenium/webdriver/common/interactions/interaction.rb +50 -0
- data/lib/selenium/webdriver/{safari/browser.rb → common/interactions/interactions.rb} +16 -15
- data/lib/selenium/webdriver/common/interactions/key_actions.rb +143 -0
- data/lib/selenium/webdriver/common/interactions/key_input.rb +62 -0
- data/lib/selenium/webdriver/{android.rb → common/interactions/none_input.rb} +11 -6
- data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +353 -0
- data/lib/selenium/webdriver/common/interactions/pointer_input.rb +132 -0
- data/lib/selenium/webdriver/common/keyboard.rb +7 -14
- data/lib/selenium/webdriver/common/keys.rb +99 -82
- data/lib/selenium/webdriver/common/log_entry.rb +3 -6
- data/lib/selenium/webdriver/common/logger.rb +140 -0
- data/lib/selenium/webdriver/common/logs.rb +2 -6
- data/lib/selenium/webdriver/common/mouse.rb +9 -14
- data/lib/selenium/webdriver/common/navigation.rb +2 -6
- data/lib/selenium/webdriver/common/options.rb +20 -23
- data/lib/selenium/webdriver/common/platform.rb +70 -97
- data/lib/selenium/webdriver/common/port_prober.rb +3 -4
- data/lib/selenium/webdriver/common/profile_helper.rb +6 -11
- data/lib/selenium/webdriver/common/proxy.rb +58 -72
- data/lib/selenium/webdriver/common/search_context.rb +22 -29
- data/lib/selenium/webdriver/common/service.rb +161 -0
- data/lib/selenium/webdriver/common/socket_lock.rb +6 -14
- data/lib/selenium/webdriver/common/socket_poller.rb +5 -12
- data/lib/selenium/webdriver/common/target_locator.rb +11 -15
- data/lib/selenium/webdriver/common/timeouts.rb +4 -8
- data/lib/selenium/webdriver/common/touch_action_builder.rb +2 -6
- data/lib/selenium/webdriver/common/touch_screen.rb +19 -23
- data/lib/selenium/webdriver/common/w3c_action_builder.rb +209 -0
- data/lib/selenium/webdriver/{phantomjs.rb → common/w3c_options.rb} +16 -14
- data/lib/selenium/webdriver/common/wait.rb +6 -13
- data/lib/selenium/webdriver/common/window.rb +48 -17
- data/lib/selenium/webdriver/common/zipper.rb +6 -10
- data/lib/selenium/webdriver/edge.rb +5 -12
- data/lib/selenium/webdriver/edge/bridge.rb +32 -63
- data/lib/selenium/webdriver/edge/driver.rb +73 -0
- data/lib/selenium/webdriver/edge/service.rb +18 -87
- data/lib/selenium/webdriver/firefox.rb +20 -11
- data/lib/selenium/webdriver/firefox/binary.rb +40 -56
- data/lib/selenium/webdriver/firefox/driver.rb +48 -0
- data/lib/selenium/webdriver/firefox/extension.rb +18 -8
- data/lib/selenium/webdriver/firefox/extension/prefs.json +3 -11
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/launcher.rb +13 -22
- data/lib/selenium/webdriver/firefox/legacy/driver.rb +79 -0
- data/lib/selenium/webdriver/{iphone.rb → firefox/marionette/bridge.rb} +25 -6
- data/lib/selenium/webdriver/firefox/marionette/driver.rb +96 -0
- data/lib/selenium/webdriver/firefox/options.rb +149 -0
- data/lib/selenium/webdriver/firefox/profile.rb +46 -46
- data/lib/selenium/webdriver/firefox/profiles_ini.rb +8 -18
- data/lib/selenium/webdriver/firefox/service.rb +23 -83
- data/lib/selenium/webdriver/firefox/util.rb +0 -4
- data/lib/selenium/webdriver/ie.rb +4 -8
- data/lib/selenium/webdriver/ie/driver.rb +90 -0
- data/lib/selenium/webdriver/ie/options.rb +136 -0
- data/lib/selenium/webdriver/ie/service.rb +58 -0
- data/lib/selenium/webdriver/remote.rb +8 -16
- data/lib/selenium/webdriver/remote/bridge.rb +96 -565
- data/lib/selenium/webdriver/remote/capabilities.rb +76 -94
- data/lib/selenium/webdriver/remote/driver.rb +49 -0
- data/lib/selenium/webdriver/remote/http/common.rb +22 -20
- data/lib/selenium/webdriver/remote/http/curb.rb +9 -12
- data/lib/selenium/webdriver/remote/http/default.rb +54 -41
- data/lib/selenium/webdriver/remote/http/persistent.rb +9 -8
- data/lib/selenium/webdriver/remote/oss/bridge.rb +586 -0
- data/lib/selenium/webdriver/remote/oss/commands.rb +221 -0
- data/lib/selenium/webdriver/remote/response.rb +39 -27
- data/lib/selenium/webdriver/remote/server_error.rb +1 -5
- data/lib/selenium/webdriver/remote/w3c/bridge.rb +573 -0
- data/lib/selenium/webdriver/remote/w3c/capabilities.rb +290 -0
- data/lib/selenium/webdriver/remote/w3c/commands.rb +148 -0
- data/lib/selenium/webdriver/safari.rb +20 -29
- data/lib/selenium/webdriver/{firefox/w3c_bridge.rb → safari/driver.rb} +21 -30
- data/lib/selenium/webdriver/safari/service.rb +57 -0
- data/lib/selenium/webdriver/support.rb +1 -2
- data/lib/selenium/webdriver/support/abstract_event_listener.rb +17 -4
- data/lib/selenium/webdriver/support/block_event_listener.rb +1 -5
- data/lib/selenium/webdriver/support/color.rb +57 -42
- data/lib/selenium/webdriver/support/escaper.rb +41 -0
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +36 -40
- data/lib/selenium/webdriver/support/select.rb +33 -86
- data/selenium-webdriver.gemspec +22 -25
- metadata +254 -261
- data/lib/selenium-client.rb +0 -21
- data/lib/selenium/client.rb +0 -57
- data/lib/selenium/client/base.rb +0 -151
- data/lib/selenium/client/driver.rb +0 -29
- data/lib/selenium/client/errors.rb +0 -28
- data/lib/selenium/client/extensions.rb +0 -132
- data/lib/selenium/client/idiomatic.rb +0 -507
- data/lib/selenium/client/javascript_expression_builder.rb +0 -135
- data/lib/selenium/client/javascript_frameworks/jquery.rb +0 -32
- data/lib/selenium/client/javascript_frameworks/prototype.rb +0 -32
- data/lib/selenium/client/legacy_driver.rb +0 -1722
- data/lib/selenium/client/protocol.rb +0 -123
- data/lib/selenium/client/selenium_helper.rb +0 -49
- data/lib/selenium/rake/server_task.rb +0 -176
- data/lib/selenium/webdriver/android/bridge.rb +0 -68
- data/lib/selenium/webdriver/chrome/bridge.rb +0 -139
- data/lib/selenium/webdriver/common/core_ext/base64.rb +0 -28
- data/lib/selenium/webdriver/common/core_ext/dir.rb +0 -61
- data/lib/selenium/webdriver/common/html5/location.rb +0 -19
- data/lib/selenium/webdriver/common/w3c_error.rb +0 -194
- data/lib/selenium/webdriver/edge/legacy_support.rb +0 -117
- data/lib/selenium/webdriver/firefox/bridge.rb +0 -89
- data/lib/selenium/webdriver/ie/bridge.rb +0 -88
- data/lib/selenium/webdriver/ie/server.rb +0 -133
- data/lib/selenium/webdriver/iphone/bridge.rb +0 -64
- data/lib/selenium/webdriver/phantomjs/bridge.rb +0 -78
- data/lib/selenium/webdriver/phantomjs/service.rb +0 -130
- data/lib/selenium/webdriver/remote/commands.rb +0 -211
- data/lib/selenium/webdriver/remote/w3c_bridge.rb +0 -668
- data/lib/selenium/webdriver/remote/w3c_capabilities.rb +0 -236
- data/lib/selenium/webdriver/remote/w3c_commands.rb +0 -132
- data/lib/selenium/webdriver/safari/bridge.rb +0 -135
- data/lib/selenium/webdriver/safari/resources/client.js +0 -7255
- data/lib/selenium/webdriver/safari/server.rb +0 -187
@@ -1,88 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
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 IE
|
23
|
-
|
24
|
-
#
|
25
|
-
# @api private
|
26
|
-
#
|
27
|
-
|
28
|
-
class Bridge < Remote::Bridge
|
29
|
-
|
30
|
-
HOST = Platform.localhost
|
31
|
-
DEFAULT_PORT = 5555
|
32
|
-
DEFAULT_TIMEOUT = 30
|
33
|
-
|
34
|
-
def initialize(opts = {})
|
35
|
-
caps = opts.delete(:desired_capabilities) { Remote::Capabilities.internet_explorer }
|
36
|
-
timeout = opts.delete(:timeout) { DEFAULT_TIMEOUT }
|
37
|
-
port = opts.delete(:port) { DEFAULT_PORT }
|
38
|
-
http_client = opts.delete(:http_client)
|
39
|
-
ignore_mode = opts.delete(:introduce_flakiness_by_ignoring_security_domains)
|
40
|
-
native_events = opts.delete(:native_events) != false
|
41
|
-
implementation = opts.delete(:implementation)
|
42
|
-
|
43
|
-
@server = Server.get(:implementation => implementation)
|
44
|
-
|
45
|
-
@server.log_level = opts.delete(:log_level) if opts[:log_level]
|
46
|
-
@server.log_file = opts.delete(:log_file) if opts[:log_file]
|
47
|
-
|
48
|
-
unless opts.empty?
|
49
|
-
raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
|
50
|
-
end
|
51
|
-
|
52
|
-
@port = @server.start Integer(port), timeout
|
53
|
-
|
54
|
-
if ignore_mode
|
55
|
-
caps['ignoreProtectedModeSettings'] = true
|
56
|
-
end
|
57
|
-
|
58
|
-
caps['nativeEvents'] = native_events
|
59
|
-
|
60
|
-
remote_opts = {
|
61
|
-
:url => @server.uri,
|
62
|
-
:desired_capabilities => caps
|
63
|
-
}
|
64
|
-
|
65
|
-
remote_opts[:http_client] = http_client if http_client
|
66
|
-
|
67
|
-
super(remote_opts)
|
68
|
-
end
|
69
|
-
|
70
|
-
def browser
|
71
|
-
:internet_explorer
|
72
|
-
end
|
73
|
-
|
74
|
-
def driver_extensions
|
75
|
-
[DriverExtensions::TakesScreenshot, DriverExtensions::HasInputDevices]
|
76
|
-
end
|
77
|
-
|
78
|
-
def quit
|
79
|
-
super
|
80
|
-
nil
|
81
|
-
ensure
|
82
|
-
@server.stop
|
83
|
-
end
|
84
|
-
|
85
|
-
end # Bridge
|
86
|
-
end # IE
|
87
|
-
end # WebDriver
|
88
|
-
end # Selenium
|
@@ -1,133 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
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 IE
|
23
|
-
|
24
|
-
#
|
25
|
-
# @api private
|
26
|
-
#
|
27
|
-
|
28
|
-
class Server
|
29
|
-
|
30
|
-
STOP_TIMEOUT = 5
|
31
|
-
SOCKET_LOCK_TIMEOUT = 45
|
32
|
-
MISSING_TEXT = "Unable to find standalone executable. Please download the IEDriverServer from http://selenium-release.storage.googleapis.com/index.html and place the executable on your PATH."
|
33
|
-
|
34
|
-
def self.get(opts = {})
|
35
|
-
binary = IE.driver_path || Platform.find_binary("IEDriverServer")
|
36
|
-
|
37
|
-
if binary
|
38
|
-
new binary, opts
|
39
|
-
else
|
40
|
-
raise Error::WebDriverError, MISSING_TEXT
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
attr_accessor :log_level, :log_file
|
45
|
-
|
46
|
-
def initialize(binary_path, opts = {})
|
47
|
-
Platform.assert_executable binary_path
|
48
|
-
|
49
|
-
@binary_path = binary_path
|
50
|
-
@process = nil
|
51
|
-
|
52
|
-
opts = opts.dup
|
53
|
-
|
54
|
-
@log_level = opts.delete(:log_level)
|
55
|
-
@log_file = opts.delete(:log_file)
|
56
|
-
@implementation = opts.delete(:implementation)
|
57
|
-
|
58
|
-
unless opts.empty?
|
59
|
-
raise ArgumentError, "invalid option#{'s' if opts.size != 1}: #{opts.inspect}"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def start(port, timeout)
|
64
|
-
return @port if running?
|
65
|
-
|
66
|
-
@port = port
|
67
|
-
socket_lock.locked do
|
68
|
-
find_free_port
|
69
|
-
start_process
|
70
|
-
connect_until_stable(timeout)
|
71
|
-
end
|
72
|
-
|
73
|
-
Platform.exit_hook { stop } # make sure we don't leave the server running
|
74
|
-
|
75
|
-
@port
|
76
|
-
end
|
77
|
-
|
78
|
-
def stop
|
79
|
-
if running?
|
80
|
-
@process.stop STOP_TIMEOUT
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def port
|
85
|
-
@port
|
86
|
-
end
|
87
|
-
|
88
|
-
def uri
|
89
|
-
"http://#{Platform.localhost}:#{port}"
|
90
|
-
end
|
91
|
-
|
92
|
-
def running?
|
93
|
-
@process && @process.alive?
|
94
|
-
end
|
95
|
-
|
96
|
-
private
|
97
|
-
|
98
|
-
def server_args
|
99
|
-
args = ["--port=#{@port}"]
|
100
|
-
|
101
|
-
args << "--log-level=#{@log_level.to_s.upcase}" if @log_level
|
102
|
-
args << "--log-file=#{@log_file}" if @log_file
|
103
|
-
args << "--implementation=#{@implementation.to_s.upcase}" if @implementation
|
104
|
-
|
105
|
-
args
|
106
|
-
end
|
107
|
-
|
108
|
-
def find_free_port
|
109
|
-
@port = PortProber.above @port
|
110
|
-
end
|
111
|
-
|
112
|
-
def start_process
|
113
|
-
@process = ChildProcess.new(@binary_path, *server_args)
|
114
|
-
@process.io.inherit! if $DEBUG
|
115
|
-
@process.start
|
116
|
-
end
|
117
|
-
|
118
|
-
def connect_until_stable(timeout)
|
119
|
-
socket_poller = SocketPoller.new Platform.localhost, @port, timeout
|
120
|
-
|
121
|
-
unless socket_poller.connected?
|
122
|
-
raise Error::WebDriverError, "unable to connect to IE server within #{timeout} seconds"
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
def socket_lock
|
127
|
-
@socket_lock ||= SocketLock.new(@port - 1, SOCKET_LOCK_TIMEOUT)
|
128
|
-
end
|
129
|
-
|
130
|
-
end # Server
|
131
|
-
end # IE
|
132
|
-
end # WebDriver
|
133
|
-
end # Selenium
|
@@ -1,64 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
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 IPhone
|
23
|
-
#
|
24
|
-
# @api private
|
25
|
-
#
|
26
|
-
|
27
|
-
class Bridge < Remote::Bridge
|
28
|
-
|
29
|
-
DEFAULT_URL = "http://#{Platform.localhost}:3001/wd/hub/"
|
30
|
-
|
31
|
-
def initialize(opts = {})
|
32
|
-
warn 'The iPhone driver is deprecated - please use either http://appium.io/ or http://ios-driver.github.io/ios-driver/ instead'
|
33
|
-
|
34
|
-
remote_opts = {
|
35
|
-
:url => opts.fetch(:url, DEFAULT_URL),
|
36
|
-
:desired_capabilities => opts.fetch(:desired_capabilities, capabilities),
|
37
|
-
}
|
38
|
-
|
39
|
-
remote_opts[:http_client] = opts[:http_client] if opts.has_key?(:http_client)
|
40
|
-
|
41
|
-
super remote_opts
|
42
|
-
end
|
43
|
-
|
44
|
-
def browser
|
45
|
-
:iphone
|
46
|
-
end
|
47
|
-
|
48
|
-
def driver_extensions
|
49
|
-
[
|
50
|
-
DriverExtensions::TakesScreenshot,
|
51
|
-
DriverExtensions::HasInputDevices,
|
52
|
-
DriverExtensions::HasWebStorage,
|
53
|
-
DriverExtensions::HasLocation
|
54
|
-
]
|
55
|
-
end
|
56
|
-
|
57
|
-
def capabilities
|
58
|
-
@capabilities ||= Remote::Capabilities.iphone
|
59
|
-
end
|
60
|
-
|
61
|
-
end # Bridge
|
62
|
-
end # IPhone
|
63
|
-
end # WebDriver
|
64
|
-
end # Selenium
|
@@ -1,78 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
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 PhantomJS
|
23
|
-
|
24
|
-
|
25
|
-
# @api private
|
26
|
-
class Bridge < Remote::Bridge
|
27
|
-
|
28
|
-
def initialize(opts = {})
|
29
|
-
http_client = opts.delete(:http_client)
|
30
|
-
caps = opts.delete(:desired_capabilities) { Remote::Capabilities.phantomjs }
|
31
|
-
|
32
|
-
if opts.has_key?(:url)
|
33
|
-
url = opts.delete(:url)
|
34
|
-
else
|
35
|
-
args = opts.delete(:args) || caps['phantomjs.cli.args']
|
36
|
-
port = opts.delete(:port)
|
37
|
-
|
38
|
-
@service = Service.default_service(port)
|
39
|
-
@service.start(args)
|
40
|
-
|
41
|
-
url = @service.uri
|
42
|
-
end
|
43
|
-
|
44
|
-
remote_opts = {
|
45
|
-
:url => url,
|
46
|
-
:desired_capabilities => caps
|
47
|
-
}
|
48
|
-
|
49
|
-
remote_opts.merge!(:http_client => http_client) if http_client
|
50
|
-
|
51
|
-
super(remote_opts)
|
52
|
-
end
|
53
|
-
|
54
|
-
def browser
|
55
|
-
:phantomjs
|
56
|
-
end
|
57
|
-
|
58
|
-
def driver_extensions
|
59
|
-
[
|
60
|
-
DriverExtensions::TakesScreenshot,
|
61
|
-
DriverExtensions::HasInputDevices
|
62
|
-
]
|
63
|
-
end
|
64
|
-
|
65
|
-
def capabilities
|
66
|
-
@capabilities ||= Remote::Capabilities.phantomjs
|
67
|
-
end
|
68
|
-
|
69
|
-
def quit
|
70
|
-
super
|
71
|
-
ensure
|
72
|
-
@service.stop if @service
|
73
|
-
end
|
74
|
-
|
75
|
-
end # Bridge
|
76
|
-
end # PhantomJS
|
77
|
-
end # WebDriver
|
78
|
-
end # Selenium
|
@@ -1,130 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
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 PhantomJS
|
23
|
-
|
24
|
-
#
|
25
|
-
# @api private
|
26
|
-
#
|
27
|
-
|
28
|
-
class Service
|
29
|
-
START_TIMEOUT = 20
|
30
|
-
SOCKET_LOCK_TIMEOUT = 45
|
31
|
-
STOP_TIMEOUT = 5
|
32
|
-
DEFAULT_PORT = 8910
|
33
|
-
MISSING_TEXT = "Unable to find phantomjs executable."
|
34
|
-
|
35
|
-
def self.executable_path
|
36
|
-
@executable_path ||= (
|
37
|
-
path = PhantomJS.path
|
38
|
-
path or raise Error::WebDriverError, MISSING_TEXT
|
39
|
-
Platform.assert_executable path
|
40
|
-
|
41
|
-
path
|
42
|
-
)
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.default_service(port = nil)
|
46
|
-
new executable_path, DEFAULT_PORT
|
47
|
-
end
|
48
|
-
|
49
|
-
def initialize(executable_path, port)
|
50
|
-
@host = Platform.localhost
|
51
|
-
@executable = executable_path
|
52
|
-
@port = Integer(port)
|
53
|
-
end
|
54
|
-
|
55
|
-
def start(args = [])
|
56
|
-
if @process && @process.alive?
|
57
|
-
raise "already started: #{uri.inspect} #{@executable.inspect}"
|
58
|
-
end
|
59
|
-
|
60
|
-
Platform.exit_hook { stop } # make sure we don't leave the server running
|
61
|
-
|
62
|
-
socket_lock.locked do
|
63
|
-
find_free_port
|
64
|
-
start_process(args)
|
65
|
-
connect_until_stable
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def stop
|
70
|
-
return if @process.nil? || @process.exited?
|
71
|
-
|
72
|
-
Net::HTTP.start(@host, @port) do |http|
|
73
|
-
http.open_timeout = STOP_TIMEOUT / 2
|
74
|
-
http.read_timeout = STOP_TIMEOUT / 2
|
75
|
-
|
76
|
-
http.get("/shutdown")
|
77
|
-
end
|
78
|
-
ensure
|
79
|
-
stop_process
|
80
|
-
if Platform.jruby? && !$DEBUG
|
81
|
-
@process.io.close rescue nil
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def find_free_port
|
86
|
-
@port = PortProber.above @port
|
87
|
-
end
|
88
|
-
|
89
|
-
def uri
|
90
|
-
URI.parse "http://#{@host}:#{@port}"
|
91
|
-
end
|
92
|
-
|
93
|
-
private
|
94
|
-
|
95
|
-
def start_process(args)
|
96
|
-
server_command = [@executable, "--webdriver=#{@port}", *args]
|
97
|
-
@process = ChildProcess.build(*server_command.compact)
|
98
|
-
|
99
|
-
if $DEBUG == true
|
100
|
-
@process.io.inherit!
|
101
|
-
elsif Platform.jruby?
|
102
|
-
# apparently we need to read the output for phantomjs to work on jruby
|
103
|
-
@process.io.stdout = @process.io.stderr = File.new(Platform.null_device, 'w')
|
104
|
-
end
|
105
|
-
|
106
|
-
@process.start
|
107
|
-
end
|
108
|
-
|
109
|
-
def stop_process
|
110
|
-
@process.poll_for_exit STOP_TIMEOUT
|
111
|
-
rescue ChildProcess::TimeoutError
|
112
|
-
@process.stop STOP_TIMEOUT
|
113
|
-
end
|
114
|
-
|
115
|
-
def connect_until_stable
|
116
|
-
socket_poller = SocketPoller.new @host, @port, START_TIMEOUT
|
117
|
-
|
118
|
-
unless socket_poller.connected?
|
119
|
-
raise Error::WebDriverError, "unable to connect to phantomjs @ #{uri} after #{START_TIMEOUT} seconds"
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
def socket_lock
|
124
|
-
@socket_lock ||= SocketLock.new(@port - 1, SOCKET_LOCK_TIMEOUT)
|
125
|
-
end
|
126
|
-
|
127
|
-
end # Service
|
128
|
-
end # PhantomJS
|
129
|
-
end # WebDriver
|
130
|
-
end # Service
|