browserstack-webdriver 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGES +791 -0
- data/README.md +31 -0
- data/build.desc +334 -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 +132 -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 +248 -0
- data/lib/selenium/webdriver.rb +71 -0
- data/lib/selenium/webdriver/android.rb +9 -0
- data/lib/selenium/webdriver/android/bridge.rb +47 -0
- data/lib/selenium/webdriver/chrome.rb +26 -0
- data/lib/selenium/webdriver/chrome/bridge.rb +120 -0
- data/lib/selenium/webdriver/chrome/profile.rb +90 -0
- data/lib/selenium/webdriver/chrome/service.rb +75 -0
- data/lib/selenium/webdriver/common.rb +44 -0
- data/lib/selenium/webdriver/common/action_builder.rb +352 -0
- data/lib/selenium/webdriver/common/alert.rb +30 -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_browser_connection.rb +17 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb +39 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +25 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +13 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +22 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +19 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +22 -0
- data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +45 -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 +293 -0
- data/lib/selenium/webdriver/common/error.rb +207 -0
- data/lib/selenium/webdriver/common/file_reaper.rb +47 -0
- data/lib/selenium/webdriver/common/html5/local_storage.rb +42 -0
- data/lib/selenium/webdriver/common/html5/location.rb +0 -0
- data/lib/selenium/webdriver/common/html5/session_storage.rb +44 -0
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +42 -0
- data/lib/selenium/webdriver/common/json_helper.rb +34 -0
- data/lib/selenium/webdriver/common/keyboard.rb +55 -0
- data/lib/selenium/webdriver/common/keys.rb +109 -0
- data/lib/selenium/webdriver/common/log_entry.rb +29 -0
- data/lib/selenium/webdriver/common/logs.rb +23 -0
- data/lib/selenium/webdriver/common/mouse.rb +72 -0
- data/lib/selenium/webdriver/common/navigation.rb +43 -0
- data/lib/selenium/webdriver/common/options.rb +136 -0
- data/lib/selenium/webdriver/common/platform.rb +218 -0
- data/lib/selenium/webdriver/common/port_prober.rb +42 -0
- data/lib/selenium/webdriver/common/profile_helper.rb +67 -0
- data/lib/selenium/webdriver/common/proxy.rb +149 -0
- data/lib/selenium/webdriver/common/search_context.rb +92 -0
- data/lib/selenium/webdriver/common/socket_poller.rb +105 -0
- data/lib/selenium/webdriver/common/target_locator.rb +81 -0
- data/lib/selenium/webdriver/common/timeouts.rb +38 -0
- data/lib/selenium/webdriver/common/touch_action_builder.rb +64 -0
- data/lib/selenium/webdriver/common/touch_screen.rb +105 -0
- data/lib/selenium/webdriver/common/wait.rb +63 -0
- data/lib/selenium/webdriver/common/window.rb +104 -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 +158 -0
- data/lib/selenium/webdriver/firefox/bridge.rb +70 -0
- data/lib/selenium/webdriver/firefox/extension.rb +52 -0
- data/lib/selenium/webdriver/firefox/launcher.rb +106 -0
- data/lib/selenium/webdriver/firefox/profile.rb +263 -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 +68 -0
- data/lib/selenium/webdriver/ie/server.rb +86 -0
- data/lib/selenium/webdriver/iphone.rb +9 -0
- data/lib/selenium/webdriver/iphone/bridge.rb +45 -0
- data/lib/selenium/webdriver/opera.rb +24 -0
- data/lib/selenium/webdriver/opera/bridge.rb +112 -0
- data/lib/selenium/webdriver/opera/service.rb +49 -0
- data/lib/selenium/webdriver/phantomjs.rb +22 -0
- data/lib/selenium/webdriver/phantomjs/bridge.rb +59 -0
- data/lib/selenium/webdriver/phantomjs/service.rb +90 -0
- data/lib/selenium/webdriver/remote.rb +22 -0
- data/lib/selenium/webdriver/remote/bridge.rb +644 -0
- data/lib/selenium/webdriver/remote/capabilities.rb +267 -0
- data/lib/selenium/webdriver/remote/commands.rb +193 -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 +139 -0
- data/lib/selenium/webdriver/remote/http/persistent.rb +38 -0
- data/lib/selenium/webdriver/remote/response.rb +97 -0
- data/lib/selenium/webdriver/remote/server_error.rb +17 -0
- data/lib/selenium/webdriver/safari.rb +46 -0
- data/lib/selenium/webdriver/safari/bridge.rb +110 -0
- data/lib/selenium/webdriver/safari/browser.rb +20 -0
- data/lib/selenium/webdriver/safari/extension.rb +120 -0
- data/lib/selenium/webdriver/safari/server.rb +145 -0
- data/lib/selenium/webdriver/support.rb +5 -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/color.rb +110 -0
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +112 -0
- data/lib/selenium/webdriver/support/select.rb +293 -0
- data/ruby.iml +13 -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 +31 -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/api/webdriver_backed_spec.rb +21 -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 +139 -0
- data/spec/integration/selenium/webdriver/app_cache_spec.rb +47 -0
- data/spec/integration/selenium/webdriver/browser_connection_spec.rb +20 -0
- data/spec/integration/selenium/webdriver/chrome/driver_spec.rb +28 -0
- data/spec/integration/selenium/webdriver/chrome/profile_spec.rb +63 -0
- data/spec/integration/selenium/webdriver/driver_spec.rb +266 -0
- data/spec/integration/selenium/webdriver/element_spec.rb +191 -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/location_spec.rb +29 -0
- data/spec/integration/selenium/webdriver/mouse_spec.rb +57 -0
- data/spec/integration/selenium/webdriver/navigation_spec.rb +46 -0
- data/spec/integration/selenium/webdriver/opera/driver_spec.rb +47 -0
- data/spec/integration/selenium/webdriver/options_spec.rb +77 -0
- data/spec/integration/selenium/webdriver/remote/driver_spec.rb +19 -0
- data/spec/integration/selenium/webdriver/remote/element_spec.rb +26 -0
- data/spec/integration/selenium/webdriver/spec_helper.rb +36 -0
- data/spec/integration/selenium/webdriver/spec_support.rb +12 -0
- data/spec/integration/selenium/webdriver/spec_support/guards.rb +110 -0
- data/spec/integration/selenium/webdriver/spec_support/helpers.rb +51 -0
- data/spec/integration/selenium/webdriver/spec_support/rack_server.rb +123 -0
- data/spec/integration/selenium/webdriver/spec_support/test_environment.rb +239 -0
- data/spec/integration/selenium/webdriver/sql_database_spec.rb +59 -0
- data/spec/integration/selenium/webdriver/storage_spec.rb +96 -0
- data/spec/integration/selenium/webdriver/target_locator_spec.rb +186 -0
- data/spec/integration/selenium/webdriver/timeout_spec.rb +69 -0
- data/spec/integration/selenium/webdriver/touch_spec.rb +176 -0
- data/spec/integration/selenium/webdriver/window_spec.rb +70 -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 +150 -0
- data/spec/unit/selenium/webdriver/action_builder_spec.rb +97 -0
- data/spec/unit/selenium/webdriver/android/bridge_spec.rb +43 -0
- data/spec/unit/selenium/webdriver/chrome/bridge_spec.rb +137 -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 +47 -0
- data/spec/unit/selenium/webdriver/ie/bridge_spec.rb +91 -0
- data/spec/unit/selenium/webdriver/iphone/bridge_spec.rb +42 -0
- data/spec/unit/selenium/webdriver/log_entry_spec.rb +11 -0
- data/spec/unit/selenium/webdriver/opera/bridge_spec.rb +44 -0
- data/spec/unit/selenium/webdriver/phantomjs/bridge_spec.rb +55 -0
- data/spec/unit/selenium/webdriver/proxy_spec.rb +106 -0
- data/spec/unit/selenium/webdriver/remote/bridge_spec.rb +16 -0
- data/spec/unit/selenium/webdriver/remote/capabilities_spec.rb +115 -0
- data/spec/unit/selenium/webdriver/remote/http/common_spec.rb +24 -0
- data/spec/unit/selenium/webdriver/remote/http/default_spec.rb +124 -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 +27 -0
- data/spec/unit/selenium/webdriver/support/color_spec.rb +119 -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 +49 -0
- metadata +370 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
require File.expand_path("../../spec_helper", __FILE__)
|
2
|
+
|
3
|
+
|
4
|
+
module Selenium
|
5
|
+
module WebDriver
|
6
|
+
module IE
|
7
|
+
|
8
|
+
describe Bridge do
|
9
|
+
let(:resp) { {"sessionId" => "foo", "value" => @default_capabilities.as_json }}
|
10
|
+
let(:server) { double(Server, :start => 5555, :uri => "http://example.com") }
|
11
|
+
let(:caps) { {} }
|
12
|
+
let(:http) { double(Remote::Http::Default, :call => resp).as_null_object }
|
13
|
+
|
14
|
+
before do
|
15
|
+
Server.stub(:get => server)
|
16
|
+
@default_capabilities = Remote::Capabilities.internet_explorer
|
17
|
+
Remote::Capabilities.stub(:internet_explorer => caps)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "raises ArgumentError if passed invalid options" do
|
21
|
+
lambda { Bridge.new(:foo => 'bar') }.should raise_error(ArgumentError)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "accepts the :introduce_flakiness_by_ignoring_security_domains option" do
|
25
|
+
Bridge.new(
|
26
|
+
:introduce_flakiness_by_ignoring_security_domains => true,
|
27
|
+
:http_client => http
|
28
|
+
)
|
29
|
+
|
30
|
+
caps['ignoreProtectedModeSettings'].should be_true
|
31
|
+
end
|
32
|
+
|
33
|
+
it "has native events enabled by default" do
|
34
|
+
Bridge.new(:http_client => http)
|
35
|
+
|
36
|
+
caps['nativeEvents'].should be_true
|
37
|
+
end
|
38
|
+
|
39
|
+
it "can disable native events" do
|
40
|
+
Bridge.new(
|
41
|
+
:native_events => false,
|
42
|
+
:http_client => http
|
43
|
+
)
|
44
|
+
|
45
|
+
caps['nativeEvents'].should be_false
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'sets the server log level and log file' do
|
49
|
+
server.should_receive(:log_level=).with :trace
|
50
|
+
server.should_receive(:log_file=).with '/foo/bar'
|
51
|
+
|
52
|
+
Bridge.new(
|
53
|
+
:log_level => :trace,
|
54
|
+
:log_file => '/foo/bar',
|
55
|
+
:http_client => http
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'takes desired capabilities' do
|
60
|
+
custom_caps = Remote::Capabilities.new
|
61
|
+
custom_caps['ignoreProtectedModeSettings'] = true
|
62
|
+
|
63
|
+
http.should_receive(:call).with do |_, _, payload|
|
64
|
+
payload[:desiredCapabilities]['ignoreProtectedModeSettings'].should be_true
|
65
|
+
resp
|
66
|
+
end
|
67
|
+
|
68
|
+
Bridge.new(:http_client => http, :desired_capabilities => custom_caps)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'can override desired capabilities through direct arguments' do
|
72
|
+
custom_caps = Remote::Capabilities.new
|
73
|
+
custom_caps['ignoreProtectedModeSettings'] = false
|
74
|
+
|
75
|
+
http.should_receive(:call).with do |_, _, payload|
|
76
|
+
payload[:desiredCapabilities]['ignoreProtectedModeSettings'].should be_true
|
77
|
+
resp
|
78
|
+
end
|
79
|
+
|
80
|
+
Bridge.new(
|
81
|
+
:http_client => http,
|
82
|
+
:desired_capabilities => custom_caps,
|
83
|
+
:introduce_flakiness_by_ignoring_security_domains => true
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.expand_path("../../spec_helper", __FILE__)
|
2
|
+
|
3
|
+
|
4
|
+
module Selenium
|
5
|
+
module WebDriver
|
6
|
+
module IPhone
|
7
|
+
describe Bridge do
|
8
|
+
let(:default_url) { URI.parse(IPhone::Bridge::DEFAULT_URL) }
|
9
|
+
let(:resp) { {"sessionId" => "foo", "value" => Remote::Capabilities.iphone.as_json }}
|
10
|
+
let(:http) { double(Remote::Http::Default, :call => resp).as_null_object }
|
11
|
+
|
12
|
+
it "uses the default iPhone driver URL" do
|
13
|
+
http.should_receive(:server_url=).with default_url
|
14
|
+
Bridge.new(:http_client => http)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "uses the user-provided URL" do
|
18
|
+
http.should_receive(:server_url=).with URI.parse("http://example.com")
|
19
|
+
Bridge.new(:http_client => http, :url => "http://example.com")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "uses the default HTTP client when none is specified" do
|
23
|
+
Remote::Http::Default.should_receive(:new).and_return http
|
24
|
+
Bridge.new
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'takes desired capabilities' do
|
28
|
+
custom_caps = Remote::Capabilities.new
|
29
|
+
custom_caps['foo'] = 'bar'
|
30
|
+
|
31
|
+
http.should_receive(:call).with do |_, _, payload|
|
32
|
+
payload[:desiredCapabilities]['foo'].should == 'bar'
|
33
|
+
resp
|
34
|
+
end
|
35
|
+
|
36
|
+
Bridge.new(:http_client => http, :desired_capabilities => custom_caps)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end # IPhone
|
41
|
+
end # WebDriver
|
42
|
+
end # Selenium
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path("../../spec_helper", __FILE__)
|
2
|
+
|
3
|
+
module Selenium
|
4
|
+
module WebDriver
|
5
|
+
module Opera
|
6
|
+
|
7
|
+
describe Bridge do
|
8
|
+
let(:resp) { {"sessionId" => "foo", "value" => Remote::Capabilities.opera.as_json }}
|
9
|
+
let(:service) { double(Service, :start => true, :uri => "http://example.com") }
|
10
|
+
let(:http) { double(Remote::Http::Default, :call => resp).as_null_object }
|
11
|
+
|
12
|
+
before do
|
13
|
+
Service.stub(:default_service => service)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'takes desired capabilities' do
|
17
|
+
custom_caps = Remote::Capabilities.new
|
18
|
+
custom_caps['foo'] = 'bar'
|
19
|
+
|
20
|
+
http.should_receive(:call).with do |_, _, payload|
|
21
|
+
payload[:desiredCapabilities]['foo'].should == 'bar'
|
22
|
+
resp
|
23
|
+
end
|
24
|
+
|
25
|
+
Bridge.new(:http_client => http, :desired_capabilities => custom_caps)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'lets direct arguments take presedence over capabilities' do
|
29
|
+
custom_caps = Remote::Capabilities.new
|
30
|
+
custom_caps['opera.arguments'] = '--foo 1'
|
31
|
+
|
32
|
+
http.should_receive(:call).with do |_, _, payload|
|
33
|
+
payload[:desiredCapabilities]['opera.arguments'].should == '--foo 2'
|
34
|
+
resp
|
35
|
+
end
|
36
|
+
|
37
|
+
Bridge.new(:http_client => http, :desired_capabilities => custom_caps, :arguments => %w[--foo 2])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end # Opera
|
42
|
+
end # WebDriver
|
43
|
+
end # Selenium
|
44
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require File.expand_path("../../spec_helper", __FILE__)
|
2
|
+
|
3
|
+
|
4
|
+
module Selenium
|
5
|
+
module WebDriver
|
6
|
+
module PhantomJS
|
7
|
+
describe Bridge do
|
8
|
+
|
9
|
+
let(:resp) { {"sessionId" => "foo", "value" => Remote::Capabilities.phantomjs.as_json }}
|
10
|
+
let(:service) { double(Service, :start => true, :uri => "http://example.com") }
|
11
|
+
let(:http) { double(Remote::Http::Default, :call => resp).as_null_object }
|
12
|
+
|
13
|
+
before do
|
14
|
+
Service.stub(:default_service).and_return(service)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'starts the server with the given arguments' do
|
18
|
+
service.should_receive(:start).with(%w[--foo --bar])
|
19
|
+
Bridge.new(:http_client => http, :args => %w[--foo --bar])
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'reads server arguments from desired capabilities if not given directly' do
|
23
|
+
service.should_receive(:start).with(%w[--foo --bar])
|
24
|
+
|
25
|
+
caps = Remote::Capabilities.phantomjs
|
26
|
+
caps['phantomjs.cli.args'] = %w[--foo --bar]
|
27
|
+
|
28
|
+
Bridge.new(:http_client => http, :desired_capabilities => caps)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'takes desired capabilities' do
|
32
|
+
custom_caps = Remote::Capabilities.new(:browser_name => 'foo')
|
33
|
+
|
34
|
+
http.should_receive(:call).with do |verb, post, payload|
|
35
|
+
payload[:desiredCapabilities].should == custom_caps
|
36
|
+
resp
|
37
|
+
end
|
38
|
+
|
39
|
+
Bridge.new(:http_client => http, :desired_capabilities => custom_caps)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'lets direct arguments take presedence over capabilities' do
|
43
|
+
service.should_receive(:start).with(%w[--foo --bar])
|
44
|
+
|
45
|
+
caps = Remote::Capabilities.phantomjs
|
46
|
+
caps['phantomjs.cli.args'] = %w[--baz]
|
47
|
+
|
48
|
+
Bridge.new(:http_client => http, :desired_capabilities => caps, :args => %w[--foo --bar])
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end # PhantomJS
|
53
|
+
end # WebDriver
|
54
|
+
end # Selenium
|
55
|
+
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
2
|
+
|
3
|
+
module Selenium
|
4
|
+
module WebDriver
|
5
|
+
describe Proxy do
|
6
|
+
let :proxy_settings do # manual proxy settings
|
7
|
+
{
|
8
|
+
:ftp => "mythicalftpproxy:21",
|
9
|
+
:http => "mythicalproxy:80",
|
10
|
+
:no_proxy => "noproxy",
|
11
|
+
:ssl => "mythicalsslproxy",
|
12
|
+
:socks => "mythicalsocksproxy:65555",
|
13
|
+
:socks_username => "test",
|
14
|
+
:socks_password => "test",
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
let :pac_proxy_settings do
|
19
|
+
{
|
20
|
+
:pac => "http://example.com/foo.pac",
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
it "raises ArgumentError if passed invalid options" do
|
25
|
+
lambda { Proxy.new(:invalid_options => 'invalid') }.should raise_error(ArgumentError)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "raises ArgumentError if passed an invalid proxy type" do
|
29
|
+
lambda { Proxy.new(:type => :invalid) }.should raise_error(ArgumentError)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "raises ArgumentError if the proxy type is changed" do
|
33
|
+
proxy = Proxy.new(:type => :direct)
|
34
|
+
lambda { proxy.type = :system }.should raise_error(ArgumentError)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should allow valid options for a manual proxy" do
|
38
|
+
proxy = Proxy.new(proxy_settings)
|
39
|
+
|
40
|
+
proxy.ftp.should == proxy_settings[:ftp]
|
41
|
+
proxy.http.should == proxy_settings[:http]
|
42
|
+
proxy.no_proxy.should == proxy_settings[:no_proxy]
|
43
|
+
proxy.ssl.should == proxy_settings[:ssl]
|
44
|
+
proxy.socks.should == proxy_settings[:socks]
|
45
|
+
proxy.socks_username.should == proxy_settings[:socks_username]
|
46
|
+
proxy.socks_password.should == proxy_settings[:socks_password]
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should return a hash of the json properties to serialize" do
|
50
|
+
proxy_json = Proxy.new(proxy_settings).as_json
|
51
|
+
|
52
|
+
proxy_json['proxyType'].should == "MANUAL"
|
53
|
+
proxy_json['ftpProxy'].should == proxy_settings[:ftp]
|
54
|
+
proxy_json['httpProxy'].should == proxy_settings[:http]
|
55
|
+
proxy_json['noProxy'].should == proxy_settings[:no_proxy]
|
56
|
+
proxy_json['sslProxy'].should == proxy_settings[:ssl]
|
57
|
+
proxy_json['socksProxy'].should == proxy_settings[:socks]
|
58
|
+
proxy_json['socksUsername'].should == proxy_settings[:socks_username]
|
59
|
+
proxy_json['socksPassword'].should == proxy_settings[:socks_password]
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should configure a PAC proxy" do
|
63
|
+
proxy_json = Proxy.new(pac_proxy_settings).as_json
|
64
|
+
|
65
|
+
proxy_json['proxyType'].should == "PAC"
|
66
|
+
proxy_json['proxyAutoconfigUrl'].should == pac_proxy_settings[:pac]
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should configure an auto-detected proxy" do
|
70
|
+
proxy_json = Proxy.new(:auto_detect => true).as_json
|
71
|
+
|
72
|
+
proxy_json['proxyType'].should == "AUTODETECT"
|
73
|
+
proxy_json['autodetect'].should be_true
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should only add settings that are not nil" do
|
77
|
+
settings = {:type => :manual, :http => "http proxy"}
|
78
|
+
|
79
|
+
proxy = Proxy.new(settings)
|
80
|
+
proxy_json = proxy.as_json
|
81
|
+
|
82
|
+
proxy_json.delete('proxyType').should == settings[:type].to_s.upcase
|
83
|
+
proxy_json.delete('httpProxy').should == settings[:http]
|
84
|
+
|
85
|
+
proxy_json.should be_empty
|
86
|
+
end
|
87
|
+
|
88
|
+
it "returns a JSON string" do
|
89
|
+
proxy = Proxy.new(proxy_settings)
|
90
|
+
proxy.to_json.should be_kind_of(String)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "can be serialized and deserialized" do
|
94
|
+
proxy = Proxy.new(proxy_settings)
|
95
|
+
other = Proxy.json_create(proxy.as_json)
|
96
|
+
|
97
|
+
proxy.should == other
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'deserializes to nil if proxyType is UNSPECIFIED' do
|
101
|
+
Proxy.json_create('proxyType' => 'UNSPECIFIED').should be_nil
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.expand_path("../../spec_helper", __FILE__)
|
2
|
+
|
3
|
+
module Selenium
|
4
|
+
module WebDriver
|
5
|
+
module Remote
|
6
|
+
|
7
|
+
describe Bridge do
|
8
|
+
it "raises ArgumentError if passed invalid options" do
|
9
|
+
lambda { Bridge.new(:foo => 'bar') }.should raise_error(ArgumentError)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end # Remote
|
14
|
+
end # WebDriver
|
15
|
+
end # Selenium
|
16
|
+
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require File.expand_path("../../spec_helper", __FILE__)
|
2
|
+
|
3
|
+
module Selenium
|
4
|
+
module WebDriver
|
5
|
+
module Remote
|
6
|
+
describe Capabilities do
|
7
|
+
|
8
|
+
it "has default capabilities for Android" do
|
9
|
+
caps = Capabilities.android
|
10
|
+
caps.browser_name.should == "android"
|
11
|
+
caps.platform.should == :android
|
12
|
+
end
|
13
|
+
|
14
|
+
it "has default capabilities for Chrome" do
|
15
|
+
caps = Capabilities.chrome
|
16
|
+
caps.browser_name.should == "chrome"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "has default capabilities for Firefox" do
|
20
|
+
caps = Capabilities.firefox
|
21
|
+
caps.browser_name.should == "firefox"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "has default capabilities for HtmlUnit" do
|
25
|
+
caps = Capabilities.htmlunit
|
26
|
+
caps.browser_name.should == "htmlunit"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "has default capabilities for Internet Explorer" do
|
30
|
+
caps = Capabilities.internet_explorer
|
31
|
+
caps.browser_name.should == "internet explorer"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "has default capabilities for iPhone" do
|
35
|
+
caps = Capabilities.iphone
|
36
|
+
caps.browser_name.should == "iPhone"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "has default capabilities for iPad" do
|
40
|
+
caps = Capabilities.ipad
|
41
|
+
caps.browser_name.should == "iPad"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "has default capabilities for Opera" do
|
45
|
+
caps = Capabilities.opera
|
46
|
+
caps.browser_name.should == "opera"
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
it "should default to no proxy" do
|
51
|
+
Capabilities.new.proxy.should be_nil
|
52
|
+
end
|
53
|
+
|
54
|
+
it "can set and get standard capabilities" do
|
55
|
+
caps = Capabilities.new
|
56
|
+
|
57
|
+
caps.browser_name = "foo"
|
58
|
+
caps.browser_name.should == "foo"
|
59
|
+
|
60
|
+
caps.native_events = true
|
61
|
+
caps.native_events.should == true
|
62
|
+
end
|
63
|
+
|
64
|
+
it "can set and get arbitrary capabilities" do
|
65
|
+
caps = Capabilities.chrome
|
66
|
+
caps['chrome'] = :foo
|
67
|
+
caps['chrome'].should == :foo
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should set the given proxy" do
|
71
|
+
proxy = Proxy.new
|
72
|
+
capabilities = Capabilities.new(:proxy => proxy)
|
73
|
+
|
74
|
+
capabilities.proxy.should == proxy
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should accept a Hash" do
|
78
|
+
capabilities = Capabilities.new(:proxy => {:http => "foo:123"})
|
79
|
+
capabilities.proxy.http.should == "foo:123"
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should return a hash of the json properties to serialize" do
|
83
|
+
capabilities_hash = Capabilities.new(:proxy => {:http => "some value"}).as_json
|
84
|
+
proxy_hash = capabilities_hash["proxy"]
|
85
|
+
|
86
|
+
capabilities_hash["proxy"].should be_kind_of(Hash)
|
87
|
+
proxy_hash['httpProxy'].should == "some value"
|
88
|
+
proxy_hash['proxyType'].should == "MANUAL"
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should not contain proxy hash when no proxy settings" do
|
92
|
+
capabilities_hash = Capabilities.new.as_json
|
93
|
+
capabilities_hash.should_not have_key("proxy")
|
94
|
+
end
|
95
|
+
|
96
|
+
it "can merge capabilities" do
|
97
|
+
a, b = Capabilities.chrome, Capabilities.htmlunit
|
98
|
+
a.merge!(b)
|
99
|
+
|
100
|
+
a.browser_name.should == "htmlunit"
|
101
|
+
a.javascript_enabled.should be_false
|
102
|
+
end
|
103
|
+
|
104
|
+
it "can be serialized and deserialized to JSON" do
|
105
|
+
caps = Capabilities.new(:browser_name => "firefox", :custom_capability => true)
|
106
|
+
caps.should == Capabilities.json_create(caps.as_json)
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'does not camel case the :firefox_binary capability' do
|
110
|
+
Capabilities.new(:firefox_binary => "/foo/bar").as_json.should include('firefox_binary')
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|