bbc-selenium-webdriver 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +473 -0
- data/README +31 -0
- data/lib/selenium-client.rb +2 -0
- data/lib/selenium-webdriver.rb +1 -0
- data/lib/selenium/client.rb +37 -0
- data/lib/selenium/client/base.rb +118 -0
- data/lib/selenium/client/driver.rb +10 -0
- data/lib/selenium/client/errors.rb +9 -0
- data/lib/selenium/client/extensions.rb +118 -0
- data/lib/selenium/client/idiomatic.rb +488 -0
- data/lib/selenium/client/javascript_expression_builder.rb +116 -0
- data/lib/selenium/client/javascript_frameworks/jquery.rb +13 -0
- data/lib/selenium/client/javascript_frameworks/prototype.rb +13 -0
- data/lib/selenium/client/legacy_driver.rb +1720 -0
- data/lib/selenium/client/protocol.rb +104 -0
- data/lib/selenium/client/selenium_helper.rb +34 -0
- data/lib/selenium/rake/server_task.rb +157 -0
- data/lib/selenium/server.rb +223 -0
- data/lib/selenium/webdriver.rb +64 -0
- data/lib/selenium/webdriver/android.rb +9 -0
- data/lib/selenium/webdriver/android/bridge.rb +51 -0
- data/lib/selenium/webdriver/chrome.rb +26 -0
- data/lib/selenium/webdriver/chrome/bridge.rb +106 -0
- data/lib/selenium/webdriver/chrome/profile.rb +83 -0
- data/lib/selenium/webdriver/chrome/service.rb +74 -0
- data/lib/selenium/webdriver/common.rb +30 -0
- data/lib/selenium/webdriver/common/action_builder.rb +352 -0
- data/lib/selenium/webdriver/common/alert.rb +26 -0
- data/lib/selenium/webdriver/common/bridge_helper.rb +67 -0
- data/lib/selenium/webdriver/common/core_ext/base64.rb +9 -0
- data/lib/selenium/webdriver/common/core_ext/dir.rb +42 -0
- data/lib/selenium/webdriver/common/core_ext/string.rb +5 -0
- data/lib/selenium/webdriver/common/driver.rb +301 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb +39 -0
- data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +44 -0
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +43 -0
- data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +46 -0
- data/lib/selenium/webdriver/common/element.rb +262 -0
- data/lib/selenium/webdriver/common/error.rb +212 -0
- data/lib/selenium/webdriver/common/file_reaper.rb +47 -0
- data/lib/selenium/webdriver/common/keyboard.rb +52 -0
- data/lib/selenium/webdriver/common/keys.rb +109 -0
- data/lib/selenium/webdriver/common/mouse.rb +65 -0
- data/lib/selenium/webdriver/common/navigation.rb +43 -0
- data/lib/selenium/webdriver/common/options.rb +128 -0
- data/lib/selenium/webdriver/common/platform.rb +166 -0
- data/lib/selenium/webdriver/common/port_prober.rb +25 -0
- data/lib/selenium/webdriver/common/profile_helper.rb +67 -0
- data/lib/selenium/webdriver/common/proxy.rb +120 -0
- data/lib/selenium/webdriver/common/search_context.rb +92 -0
- data/lib/selenium/webdriver/common/socket_poller.rb +100 -0
- data/lib/selenium/webdriver/common/target_locator.rb +81 -0
- data/lib/selenium/webdriver/common/timeouts.rb +29 -0
- data/lib/selenium/webdriver/common/wait.rb +60 -0
- data/lib/selenium/webdriver/common/window.rb +96 -0
- data/lib/selenium/webdriver/common/zipper.rb +82 -0
- data/lib/selenium/webdriver/firefox.rb +37 -0
- data/lib/selenium/webdriver/firefox/binary.rb +161 -0
- data/lib/selenium/webdriver/firefox/bridge.rb +58 -0
- data/lib/selenium/webdriver/firefox/extension.rb +52 -0
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/launcher.rb +104 -0
- 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/firefox/profile.rb +315 -0
- data/lib/selenium/webdriver/firefox/profiles_ini.rb +62 -0
- data/lib/selenium/webdriver/firefox/socket_lock.rb +61 -0
- data/lib/selenium/webdriver/firefox/util.rb +29 -0
- data/lib/selenium/webdriver/ie.rb +19 -0
- data/lib/selenium/webdriver/ie/bridge.rb +60 -0
- data/lib/selenium/webdriver/ie/native/win32/IEDriver.dll +0 -0
- data/lib/selenium/webdriver/ie/native/x64/IEDriver.dll +0 -0
- data/lib/selenium/webdriver/ie/server.rb +64 -0
- data/lib/selenium/webdriver/iphone.rb +9 -0
- data/lib/selenium/webdriver/iphone/bridge.rb +50 -0
- data/lib/selenium/webdriver/opera.rb +24 -0
- data/lib/selenium/webdriver/opera/bridge.rb +113 -0
- data/lib/selenium/webdriver/opera/service.rb +49 -0
- data/lib/selenium/webdriver/remote.rb +21 -0
- data/lib/selenium/webdriver/remote/bridge.rb +473 -0
- data/lib/selenium/webdriver/remote/capabilities.rb +241 -0
- data/lib/selenium/webdriver/remote/commands.rb +181 -0
- data/lib/selenium/webdriver/remote/http/common.rb +74 -0
- data/lib/selenium/webdriver/remote/http/curb.rb +79 -0
- data/lib/selenium/webdriver/remote/http/default.rb +102 -0
- data/lib/selenium/webdriver/remote/http/persistent.rb +38 -0
- data/lib/selenium/webdriver/remote/response.rb +99 -0
- data/lib/selenium/webdriver/remote/server_error.rb +17 -0
- data/lib/selenium/webdriver/support.rb +4 -0
- data/lib/selenium/webdriver/support/abstract_event_listener.rb +28 -0
- data/lib/selenium/webdriver/support/block_event_listener.rb +17 -0
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +112 -0
- data/lib/selenium/webdriver/support/select.rb +293 -0
- data/spec/integration/selenium/client/api/backward_compatible_api_spec.rb +22 -0
- data/spec/integration/selenium/client/api/browser_xpath_library_spec.rb +17 -0
- data/spec/integration/selenium/client/api/click_spec.rb +39 -0
- data/spec/integration/selenium/client/api/cookie_spec.rb +39 -0
- data/spec/integration/selenium/client/api/element_spec.rb +14 -0
- data/spec/integration/selenium/client/api/highlight_located_element_spec.rb +19 -0
- data/spec/integration/selenium/client/api/retrieve_last_remote_control_logs_spec.rb +33 -0
- data/spec/integration/selenium/client/api/screenshot_spec.rb +29 -0
- data/spec/integration/selenium/client/api/select_window_spec.rb +46 -0
- data/spec/integration/selenium/client/api/start_stop_spec.rb +9 -0
- data/spec/integration/selenium/client/api/wait_for_ajax_spec.rb +27 -0
- data/spec/integration/selenium/client/api/wait_for_element_spec.rb +56 -0
- data/spec/integration/selenium/client/api/wait_for_field_value_spec.rb +52 -0
- data/spec/integration/selenium/client/api/wait_for_text_spec.rb +98 -0
- data/spec/integration/selenium/client/sample-app/public/jquery-1.3.2.js +4376 -0
- data/spec/integration/selenium/client/sample-app/public/jquery.html +55 -0
- data/spec/integration/selenium/client/sample-app/public/prototype-1.6.0.3.js +4320 -0
- data/spec/integration/selenium/client/sample-app/public/prototype.html +59 -0
- data/spec/integration/selenium/client/sample-app/sample_app.rb +32 -0
- data/spec/integration/selenium/client/spec_helper.rb +125 -0
- data/spec/integration/selenium/webdriver/chrome/driver_spec.rb +28 -0
- data/spec/integration/selenium/webdriver/chrome/profile_spec.rb +42 -0
- data/spec/integration/selenium/webdriver/driver_spec.rb +253 -0
- data/spec/integration/selenium/webdriver/element_spec.rb +185 -0
- data/spec/integration/selenium/webdriver/error_spec.rb +30 -0
- data/spec/integration/selenium/webdriver/firefox/driver_spec.rb +21 -0
- data/spec/integration/selenium/webdriver/firefox/profile_spec.rb +141 -0
- data/spec/integration/selenium/webdriver/keyboard_spec.rb +57 -0
- data/spec/integration/selenium/webdriver/mouse_spec.rb +55 -0
- data/spec/integration/selenium/webdriver/navigation_spec.rb +44 -0
- data/spec/integration/selenium/webdriver/opera/driver_spec.rb +47 -0
- data/spec/integration/selenium/webdriver/options_spec.rb +49 -0
- data/spec/integration/selenium/webdriver/remote/element_spec.rb +24 -0
- data/spec/integration/selenium/webdriver/spec_helper.rb +44 -0
- data/spec/integration/selenium/webdriver/spec_support.rb +13 -0
- data/spec/integration/selenium/webdriver/spec_support/guards.rb +86 -0
- data/spec/integration/selenium/webdriver/spec_support/helpers.rb +46 -0
- data/spec/integration/selenium/webdriver/spec_support/jruby_test_environment.rb +29 -0
- data/spec/integration/selenium/webdriver/spec_support/rack_server.rb +123 -0
- data/spec/integration/selenium/webdriver/spec_support/test_environment.rb +199 -0
- data/spec/integration/selenium/webdriver/target_locator_spec.rb +170 -0
- data/spec/integration/selenium/webdriver/timeout_spec.rb +56 -0
- data/spec/integration/selenium/webdriver/window_spec.rb +56 -0
- data/spec/integration/selenium/webdriver/zipper_spec.rb +66 -0
- data/spec/unit/selenium/client/base_spec.rb +239 -0
- data/spec/unit/selenium/client/extensions_spec.rb +174 -0
- data/spec/unit/selenium/client/idiomatic_spec.rb +500 -0
- data/spec/unit/selenium/client/javascript_expression_builder_spec.rb +79 -0
- data/spec/unit/selenium/client/javascript_frameworks/jquery_spec.rb +10 -0
- data/spec/unit/selenium/client/javascript_frameworks/prototype_spec.rb +10 -0
- data/spec/unit/selenium/client/protocol_spec.rb +124 -0
- data/spec/unit/selenium/client/selenium_helper_spec.rb +56 -0
- data/spec/unit/selenium/client/spec_helper.rb +24 -0
- data/spec/unit/selenium/rake/task_spec.rb +79 -0
- data/spec/unit/selenium/server_spec.rb +131 -0
- data/spec/unit/selenium/webdriver/action_builder_spec.rb +90 -0
- data/spec/unit/selenium/webdriver/android/bridge_spec.rb +31 -0
- data/spec/unit/selenium/webdriver/chrome/bridge_spec.rb +94 -0
- data/spec/unit/selenium/webdriver/chrome/profile_spec.rb +57 -0
- data/spec/unit/selenium/webdriver/chrome/service_spec.rb +44 -0
- data/spec/unit/selenium/webdriver/error_spec.rb +41 -0
- data/spec/unit/selenium/webdriver/firefox/bridge_spec.rb +17 -0
- data/spec/unit/selenium/webdriver/iphone/bridge_spec.rb +30 -0
- data/spec/unit/selenium/webdriver/proxy_spec.rb +87 -0
- data/spec/unit/selenium/webdriver/remote/bridge_spec.rb +16 -0
- data/spec/unit/selenium/webdriver/remote/capabilities_spec.rb +111 -0
- data/spec/unit/selenium/webdriver/remote/http/common_spec.rb +24 -0
- data/spec/unit/selenium/webdriver/remote/http/default_spec.rb +46 -0
- data/spec/unit/selenium/webdriver/search_context_spec.rb +61 -0
- data/spec/unit/selenium/webdriver/socket_poller_spec.rb +68 -0
- data/spec/unit/selenium/webdriver/spec_helper.rb +6 -0
- data/spec/unit/selenium/webdriver/support/event_firing_spec.rb +111 -0
- data/spec/unit/selenium/webdriver/support/select_spec.rb +290 -0
- data/spec/unit/selenium/webdriver/wait_spec.rb +40 -0
- metadata +215 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
module Firefox
|
4
|
+
|
5
|
+
# @api private
|
6
|
+
class ProfilesIni
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@ini_path = File.join(Util.app_data_path, "profiles.ini")
|
10
|
+
@profile_paths = {}
|
11
|
+
|
12
|
+
parse if File.exist?(@ini_path)
|
13
|
+
end
|
14
|
+
|
15
|
+
def [](name)
|
16
|
+
path = @profile_paths[name]
|
17
|
+
path && Profile.new(path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def refresh
|
21
|
+
@profile_paths.clear
|
22
|
+
parse
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def parse
|
28
|
+
string = File.read @ini_path
|
29
|
+
name = nil
|
30
|
+
is_relative = nil
|
31
|
+
path = nil
|
32
|
+
|
33
|
+
string.split("\n").each do |line|
|
34
|
+
case line
|
35
|
+
when /^\[Profile/
|
36
|
+
if p = path_for(name, is_relative, path)
|
37
|
+
@profile_paths[name] = p
|
38
|
+
name, path = nil
|
39
|
+
end
|
40
|
+
when /^Name=(.+)$/
|
41
|
+
name = $1.strip
|
42
|
+
when /^IsRelative=(.+)$/
|
43
|
+
is_relative = $1.strip == "1"
|
44
|
+
when /^Path=(.+)$/
|
45
|
+
path = $1.strip
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
if p = path_for(name, is_relative, path)
|
50
|
+
@profile_paths[name] = p
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def path_for(name, is_relative, path)
|
55
|
+
return unless [name, path].any?
|
56
|
+
path = is_relative ? File.join(Util.app_data_path, path) : path
|
57
|
+
end
|
58
|
+
|
59
|
+
end # ProfilesIni
|
60
|
+
end # Firefox
|
61
|
+
end # WebDriver
|
62
|
+
end # Selenium
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
module Firefox
|
4
|
+
|
5
|
+
#
|
6
|
+
# @api private
|
7
|
+
#
|
8
|
+
|
9
|
+
class SocketLock
|
10
|
+
|
11
|
+
def initialize(port, timeout)
|
12
|
+
@port = port
|
13
|
+
@timeout = timeout
|
14
|
+
end
|
15
|
+
|
16
|
+
def locked(&blk)
|
17
|
+
lock
|
18
|
+
|
19
|
+
begin
|
20
|
+
yield
|
21
|
+
ensure
|
22
|
+
release
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def lock
|
29
|
+
max_time = Time.now + @timeout
|
30
|
+
|
31
|
+
until can_lock? || Time.now >= max_time
|
32
|
+
sleep 0.1
|
33
|
+
end
|
34
|
+
|
35
|
+
unless did_lock?
|
36
|
+
raise Error::WebDriverError, "unable to bind to locking port #{@port} within #{@timeout} seconds"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def release
|
41
|
+
@server && @server.close
|
42
|
+
end
|
43
|
+
|
44
|
+
def can_lock?
|
45
|
+
@server = TCPServer.new(Platform.localhost, @port)
|
46
|
+
ChildProcess.close_on_exec @server
|
47
|
+
|
48
|
+
true
|
49
|
+
rescue SocketError, Errno::EADDRINUSE, Errno::EBADF => ex
|
50
|
+
$stderr.puts "#{self}: #{ex.message}" if $DEBUG
|
51
|
+
false
|
52
|
+
end
|
53
|
+
|
54
|
+
def did_lock?
|
55
|
+
!!@server
|
56
|
+
end
|
57
|
+
|
58
|
+
end # SocketLock
|
59
|
+
end # Firefox
|
60
|
+
end # WebDriver
|
61
|
+
end # Selenium
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
module Firefox
|
4
|
+
|
5
|
+
# @api private
|
6
|
+
module Util
|
7
|
+
module_function
|
8
|
+
|
9
|
+
def app_data_path
|
10
|
+
case Platform.os
|
11
|
+
when :windows
|
12
|
+
"#{ENV['APPDATA']}\\Mozilla\\Firefox"
|
13
|
+
when :macosx
|
14
|
+
"#{Platform.home}/Library/Application Support/Firefox"
|
15
|
+
when :unix, :linux
|
16
|
+
"#{Platform.home}/.mozilla/firefox"
|
17
|
+
else
|
18
|
+
raise "Unknown os: #{Platform.os}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def stringified?(str)
|
23
|
+
str =~ /^".*"$/
|
24
|
+
end
|
25
|
+
|
26
|
+
end # Util
|
27
|
+
end # Firefox
|
28
|
+
end # WebDriver
|
29
|
+
end # Selenium
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
|
4
|
+
# @api private
|
5
|
+
module IE
|
6
|
+
DLLS = {
|
7
|
+
:win32 => "#{WebDriver.root}/selenium/webdriver/ie/native/win32/IEDriver.dll",
|
8
|
+
:x64 => "#{WebDriver.root}/selenium/webdriver/ie/native/x64/IEDriver.dll"
|
9
|
+
}
|
10
|
+
|
11
|
+
DLLS.each { |k,v| DLLS[k] = Platform.cygwin_path(v, :dos => true) } if Platform.cygwin?
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'ffi'
|
17
|
+
|
18
|
+
require 'selenium/webdriver/ie/server'
|
19
|
+
require 'selenium/webdriver/ie/bridge'
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
module IE
|
4
|
+
|
5
|
+
#
|
6
|
+
# @api private
|
7
|
+
#
|
8
|
+
|
9
|
+
class Bridge < Remote::Bridge
|
10
|
+
|
11
|
+
HOST = Platform.localhost
|
12
|
+
DEFAULT_PORT = 5555
|
13
|
+
DEFAULT_TIMEOUT = 30
|
14
|
+
|
15
|
+
def initialize(opts = {})
|
16
|
+
timeout = opts.delete(:timeout) { DEFAULT_TIMEOUT }
|
17
|
+
port = opts.delete(:port) { DEFAULT_PORT }
|
18
|
+
http_client = opts.delete(:http_client)
|
19
|
+
|
20
|
+
unless opts.empty?
|
21
|
+
raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
|
22
|
+
end
|
23
|
+
|
24
|
+
@server = Server.new
|
25
|
+
@port = @server.start Integer(port)
|
26
|
+
|
27
|
+
host = Platform.localhost
|
28
|
+
unless SocketPoller.new(host, @port, timeout).connected?
|
29
|
+
raise Error::WebDriverError, "unable to connect to IE server within #{timeout} seconds"
|
30
|
+
end
|
31
|
+
|
32
|
+
remote_opts = {
|
33
|
+
:url => "http://#{host}:#{@port}",
|
34
|
+
:desired_capabilities => :internet_explorer
|
35
|
+
}
|
36
|
+
|
37
|
+
remote_opts.merge!(:http_client => http_client) if http_client
|
38
|
+
|
39
|
+
super(remote_opts)
|
40
|
+
end
|
41
|
+
|
42
|
+
def browser
|
43
|
+
:internet_explorer
|
44
|
+
end
|
45
|
+
|
46
|
+
def driver_extensions
|
47
|
+
[DriverExtensions::TakesScreenshot, DriverExtensions::HasInputDevices]
|
48
|
+
end
|
49
|
+
|
50
|
+
def quit
|
51
|
+
super
|
52
|
+
@server.stop
|
53
|
+
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
|
57
|
+
end # Bridge
|
58
|
+
end # IE
|
59
|
+
end # WebDriver
|
60
|
+
end # Selenium
|
Binary file
|
Binary file
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
module IE
|
4
|
+
|
5
|
+
#
|
6
|
+
# @api private
|
7
|
+
#
|
8
|
+
|
9
|
+
class Server
|
10
|
+
extend FFI::Library
|
11
|
+
|
12
|
+
if Platform.bitsize == 64
|
13
|
+
ffi_lib WebDriver::IE::DLLS[:x64]
|
14
|
+
else
|
15
|
+
ffi_lib WebDriver::IE::DLLS[:win32]
|
16
|
+
end
|
17
|
+
|
18
|
+
ffi_convention :stdcall
|
19
|
+
|
20
|
+
attach_function :start_server, :StartServer, [:int], :pointer
|
21
|
+
attach_function :stop_server, :StopServer, [:pointer], :void
|
22
|
+
attach_function :session_count, :GetServerSessionCount, [], :int
|
23
|
+
attach_function :current_port, :GetServerPort, [], :int
|
24
|
+
attach_function :is_running, :ServerIsRunning, [], :bool
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
@handle = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
#
|
31
|
+
# Starts the server, communicating on the specified port, if it is not already running
|
32
|
+
#
|
33
|
+
|
34
|
+
def start(start_port)
|
35
|
+
return port if running?
|
36
|
+
@handle = self.class.start_server(start_port)
|
37
|
+
|
38
|
+
start_port
|
39
|
+
end
|
40
|
+
|
41
|
+
def stop
|
42
|
+
return if session_count != 0 || @handle.nil?
|
43
|
+
self.class.stop_server @handle
|
44
|
+
@handle = nil
|
45
|
+
end
|
46
|
+
|
47
|
+
def running?
|
48
|
+
self.class.is_running
|
49
|
+
end
|
50
|
+
|
51
|
+
def port
|
52
|
+
self.class.current_port
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def session_count
|
58
|
+
self.class.session_count
|
59
|
+
end
|
60
|
+
|
61
|
+
end # Server
|
62
|
+
end # IE
|
63
|
+
end # WebDriver
|
64
|
+
end # Selenium
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
module IPhone
|
4
|
+
#
|
5
|
+
# @api private
|
6
|
+
#
|
7
|
+
|
8
|
+
class Bridge < Remote::Bridge
|
9
|
+
|
10
|
+
DEFAULT_URL = "http://#{Platform.localhost}:3001/hub/"
|
11
|
+
|
12
|
+
def initialize(opts = {})
|
13
|
+
remote_opts = {
|
14
|
+
:url => opts.fetch(:url, DEFAULT_URL),
|
15
|
+
:desired_capabilities => opts.fetch(:desired_capabilities, capabilities),
|
16
|
+
}
|
17
|
+
|
18
|
+
remote_opts[:http_client] = opts[:http_client] if opts.has_key?(:http_client)
|
19
|
+
|
20
|
+
super remote_opts
|
21
|
+
end
|
22
|
+
|
23
|
+
def browser
|
24
|
+
:iphone
|
25
|
+
end
|
26
|
+
|
27
|
+
def driver_extensions
|
28
|
+
[
|
29
|
+
DriverExtensions::TakesScreenshot,
|
30
|
+
DriverExtensions::HasInputDevices,
|
31
|
+
DriverExtensions::Rotatable
|
32
|
+
]
|
33
|
+
end
|
34
|
+
|
35
|
+
def setScreenOrientation(orientation)
|
36
|
+
execute :setScreenOrientation, {}, :orientation => orientation
|
37
|
+
end
|
38
|
+
|
39
|
+
def getScreenOrientation
|
40
|
+
execute :getScreenOrientation
|
41
|
+
end
|
42
|
+
|
43
|
+
def capabilities
|
44
|
+
@capabilities ||= Remote::Capabilities.iphone
|
45
|
+
end
|
46
|
+
|
47
|
+
end # Bridge
|
48
|
+
end # IPhone
|
49
|
+
end # WebDriver
|
50
|
+
end # Selenium
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'selenium/server'
|
2
|
+
require 'selenium/webdriver/opera/service'
|
3
|
+
require 'selenium/webdriver/opera/bridge'
|
4
|
+
|
5
|
+
module Selenium
|
6
|
+
module WebDriver
|
7
|
+
|
8
|
+
module Opera
|
9
|
+
def self.driver_path=(path)
|
10
|
+
Service.selenium_server_jar = path
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.path=(path)
|
14
|
+
Platform.assert_executable path
|
15
|
+
@path = path
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.path
|
19
|
+
@path ||= nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
module Opera
|
4
|
+
|
5
|
+
#
|
6
|
+
# @api private
|
7
|
+
#
|
8
|
+
|
9
|
+
LOGGING_LEVELS = [:severe, :warning, :info, :config, :fine, :finer, :finest, :all]
|
10
|
+
|
11
|
+
class Bridge < Remote::Bridge
|
12
|
+
|
13
|
+
def initialize(opts = {})
|
14
|
+
@service = Service.default_service :log => (opts[:logging_level] ? true : false)
|
15
|
+
|
16
|
+
http_client = opts.delete(:http_client)
|
17
|
+
caps = create_capabilities(opts)
|
18
|
+
|
19
|
+
@service.start
|
20
|
+
|
21
|
+
remote_opts = {
|
22
|
+
:url => @service.uri,
|
23
|
+
:desired_capabilities => caps
|
24
|
+
}
|
25
|
+
|
26
|
+
remote_opts.merge!(:http_client => http_client) if http_client
|
27
|
+
|
28
|
+
super(remote_opts)
|
29
|
+
end
|
30
|
+
|
31
|
+
def browser
|
32
|
+
:opera
|
33
|
+
end
|
34
|
+
|
35
|
+
def driver_extensions
|
36
|
+
[
|
37
|
+
DriverExtensions::HasInputDevices,
|
38
|
+
DriverExtensions::TakesScreenshot
|
39
|
+
]
|
40
|
+
end
|
41
|
+
|
42
|
+
def capabilities
|
43
|
+
@capabilities ||= Remote::Capabilities.opera
|
44
|
+
end
|
45
|
+
|
46
|
+
def quit
|
47
|
+
super
|
48
|
+
ensure
|
49
|
+
@service.stop
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def create_capabilities(opts)
|
55
|
+
original_opts = opts.dup
|
56
|
+
|
57
|
+
arguments = opts.delete(:arguments)
|
58
|
+
logging_level = opts.delete(:logging_level)
|
59
|
+
logging_file = opts.delete(:logging_file)
|
60
|
+
host = opts.delete(:host)
|
61
|
+
port = opts.delete(:port)
|
62
|
+
launcher = opts.delete(:launcher)
|
63
|
+
profile = opts.delete(:profile)
|
64
|
+
idle = opts.delete(:idle)
|
65
|
+
display = opts.delete(:display)
|
66
|
+
autostart = opts.delete(:autostart)
|
67
|
+
no_restart = opts.delete(:no_restart)
|
68
|
+
no_quit = opts.delete(:no_quit)
|
69
|
+
product = opts.delete(:product)
|
70
|
+
|
71
|
+
unless opts.empty?
|
72
|
+
raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
|
73
|
+
end
|
74
|
+
|
75
|
+
caps = Remote::Capabilities.opera
|
76
|
+
|
77
|
+
if arguments
|
78
|
+
unless arguments.kind_of? Array
|
79
|
+
raise ArgumentError, ':arguments must be an Array of Strings'
|
80
|
+
end
|
81
|
+
|
82
|
+
caps.merge! 'opera.arguments' => arguments.join(' ')
|
83
|
+
end
|
84
|
+
|
85
|
+
if logging_level
|
86
|
+
unless LOGGING_LEVELS.include?(logging_level)
|
87
|
+
raise ArgumentError,
|
88
|
+
"unknown logging level #{logging_level.inspect}, available levels: #{LOGGING_LEVELS.inspect}"
|
89
|
+
end
|
90
|
+
|
91
|
+
caps.merge! 'opera.logging.level' => logging_level.to_s.upcase
|
92
|
+
end
|
93
|
+
|
94
|
+
caps.merge! 'opera.logging.file' => logging_file if logging_file
|
95
|
+
caps.merge! 'opera.binary' => Opera.path if Opera.path
|
96
|
+
caps.merge! 'opera.host' => host if host
|
97
|
+
caps.merge! 'opera.port' => port.to_i if port
|
98
|
+
caps.merge! 'opera.launcher' => launcher if launcher
|
99
|
+
caps.merge! 'opera.profile' => profile if original_opts.has_key?(:profile)
|
100
|
+
caps.merge! 'opera.idle' => !!idle unless idle.nil?
|
101
|
+
caps.merge! 'opera.display' => display.to_i if display
|
102
|
+
caps.merge! 'opera.autostart' => !!autostart unless autostart.nil?
|
103
|
+
caps.merge! 'opera.no_restart' => !!no_restart unless no_restart.nil?
|
104
|
+
caps.merge! 'opera.no_quit' => !!no_quit unless no_quit.nil?
|
105
|
+
caps.merge! 'opera.product' => product if product
|
106
|
+
|
107
|
+
caps
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|