browserstack-webdriver 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,79 @@
|
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
|
2
|
+
|
|
3
|
+
describe Selenium::Client::JavascriptExpressionBuilder do
|
|
4
|
+
def builder(*args)
|
|
5
|
+
@builder ||= Selenium::Client::JavascriptExpressionBuilder.new(*args)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "can append arbitrary text to builder" do
|
|
9
|
+
builder.append("hello").append(" world")
|
|
10
|
+
builder.script.should == "hello world"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "returns the correct #no_pending_ajax_requests script for Prototype" do
|
|
14
|
+
builder = builder(:prototype)
|
|
15
|
+
builder.no_pending_ajax_requests.script.should == "selenium.browserbot.getCurrentWindow().Ajax.activeRequestCount == 0;"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "returns the correct #no_pending_ajax_requests script for jQuery" do
|
|
19
|
+
builder = builder(:jquery)
|
|
20
|
+
builder.no_pending_ajax_requests.script.should == "selenium.browserbot.getCurrentWindow().jQuery.active == 0;"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "returns the correct #no_pending_effects for Prototype" do
|
|
24
|
+
builder = builder(:prototype)
|
|
25
|
+
builder.no_pending_effects.script.should == "selenium.browserbot.getCurrentWindow().Effect.Queue.size() == 0;"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe "#quote_escaped" do
|
|
29
|
+
it "returns a locator as is when it has no single quotes" do
|
|
30
|
+
builder.quote_escaped("the_locator").should == "the_locator"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "escapes single quotes" do
|
|
34
|
+
builder.quote_escaped("//div[@id='demo-effect-appear']").should == "//div[@id=\\'demo-effect-appear\\']"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "escapes backslashes" do
|
|
38
|
+
builder.quote_escaped("webratlink=evalregex:/Pastry Lovers \\(Organizer\\)/").should == "webratlink=evalregex:/Pastry Lovers \\\\(Organizer\\\\)/"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe "#text_match" do
|
|
43
|
+
it "matches on entire string when pattern is a string" do
|
|
44
|
+
builder.text_match("some text").should == "element.innerHTML == 'some text'"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "performs a regexp match when pattern is a regexp" do
|
|
48
|
+
builder.text_match(/some text/).should == "null != element.innerHTML.match(/some text/)"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "escapes rexpexp when pattern is a regexp" do
|
|
52
|
+
builder.text_match(/some.*text/).should == "null != element.innerHTML.match(/some.*text/)"
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe "#find_element" do
|
|
57
|
+
it "adds a script to find an element" do
|
|
58
|
+
builder.find_element('a_locator').script.should =~ /element\s+=\s+selenium.browserbot.findElement\('a_locator'\);/m
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "should handle embedded evalregex locators" do
|
|
62
|
+
builder.find_element("webratlink=evalregex:/Pastry Lovers \\(Organizer\\)/").script.should =~ /element\s+=\s+selenium.browserbot.findElement\('webratlink=evalregex:\/Pastry Lovers \\\\\(Organizer\\\\\)\/'\);/m
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe "#javascript_framework_for" do
|
|
67
|
+
it "returns JavascriptFrameworks::Prototype when argument is :prototype" do
|
|
68
|
+
builder.javascript_framework_for(:prototype).should == Selenium::Client::JavascriptFrameworks::Prototype
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "returns JavascriptFrameworks::JQuery when argument is :jquery" do
|
|
72
|
+
builder.javascript_framework_for(:jquery).should == Selenium::Client::JavascriptFrameworks::JQuery
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "raises a Runtime for unsupported frameworks" do
|
|
76
|
+
lambda { builder.javascript_framework_for(:unsupported_framework) }.should raise_error(RuntimeError)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require File.expand_path("../../spec_helper", __FILE__)
|
|
2
|
+
|
|
3
|
+
describe Selenium::Client::JavascriptFrameworks::JQuery do
|
|
4
|
+
|
|
5
|
+
it "returns 'jQuery.active'" do
|
|
6
|
+
art = Selenium::Client::JavascriptFrameworks::JQuery.ajax_request_tracker
|
|
7
|
+
art.should == "jQuery.active"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require File.expand_path("../../spec_helper", __FILE__)
|
|
2
|
+
|
|
3
|
+
describe Selenium::Client::JavascriptFrameworks::Prototype do
|
|
4
|
+
|
|
5
|
+
it "returns 'Ajax.activeRequestCount'" do
|
|
6
|
+
art = Selenium::Client::JavascriptFrameworks::Prototype.ajax_request_tracker
|
|
7
|
+
art.should == "Ajax.activeRequestCount"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
end
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
|
2
|
+
|
|
3
|
+
describe Selenium::Client::Protocol do
|
|
4
|
+
class ProtocolClient
|
|
5
|
+
include Selenium::Client::Protocol
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
let(:client) { ProtocolClient.new }
|
|
9
|
+
|
|
10
|
+
describe "#remote_control_command" do
|
|
11
|
+
it "returns the content of the HTTP response when the command succeeds" do
|
|
12
|
+
client.instance_variable_set :@default_timeout_in_seconds, 1
|
|
13
|
+
client.stub(:http_request_for).with(:a_verb, :some_args).and_return(:the_request)
|
|
14
|
+
client.should_receive(:http_post).with(:the_request).and_return(["OK", "OK,the response"])
|
|
15
|
+
client.remote_control_command(:a_verb, :some_args).should == "the response"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "raises a SeleniumCommandError when the command fails" do
|
|
19
|
+
client.instance_variable_set :@default_timeout_in_seconds, 1
|
|
20
|
+
client.stub(:http_request_for).with(:a_verb, :some_args).and_return(:the_request)
|
|
21
|
+
client.should_receive(:http_post).with(:the_request).and_return(["ER", "ERROR,the error message"])
|
|
22
|
+
lambda { client.remote_control_command(:a_verb, :some_args) }.should raise_error(Selenium::Client::CommandError)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "succeeds when given zero args" do
|
|
26
|
+
client.instance_variable_set :@default_timeout_in_seconds, 1
|
|
27
|
+
client.should_receive(:http_request_for).with(:a_verb, []).and_return(:the_request)
|
|
28
|
+
client.stub(:http_post).with(:the_request).and_return(["OK", "OK,the response"])
|
|
29
|
+
client.remote_control_command(:a_verb)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe "#string_command" do
|
|
34
|
+
it "returns the selenese command response" do
|
|
35
|
+
client.should_receive(:remote_control_command).with(:a_verb, :some_args).and_return("A String")
|
|
36
|
+
client.string_command(:a_verb, :some_args).should == "A String"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "succeeds when given zero args" do
|
|
40
|
+
client.should_receive(:remote_control_command).with(:a_verb, [])
|
|
41
|
+
client.string_command:a_verb
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe "#get_string" do # private?
|
|
46
|
+
it "parses the command response as a CSV row" do
|
|
47
|
+
client.should_receive(:remote_control_command).with(:a_verb, :some_args).and_return("One,Two,Three")
|
|
48
|
+
client.string_array_command(:a_verb, :some_args).should == ["One", "Two", "Three"]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "preserves spaces" do
|
|
52
|
+
client.should_receive(:remote_control_command).with(:a_verb, :some_args).and_return(" One , Two & Three ")
|
|
53
|
+
client.string_array_command(:a_verb, :some_args).should == [" One ", " Two & Three "]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "ignores commas escaped with a backspace" do
|
|
57
|
+
client.should_receive(:remote_control_command).with(:a_verb, :some_args).and_return("One,Two\\,Three")
|
|
58
|
+
client.string_array_command(:a_verb, :some_args).should == ["One", "Two,Three"]
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe "parse_boolean_value" do
|
|
63
|
+
it "returns true when string is true" do
|
|
64
|
+
client.send(:parse_boolean_value, "true").should == true
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "returns false when string is false" do
|
|
68
|
+
client.send(:parse_boolean_value, "false").should == false
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "parse_boolean_value raise a ProtocolError when string is neither true nor false" do
|
|
72
|
+
lambda {
|
|
73
|
+
client.send(:parse_boolean_value, "unexpected")
|
|
74
|
+
}.should raise_error(Selenium::Client::ProtocolError, "Invalid Selenese boolean value that is neither 'true' nor 'false': got 'unexpected'")
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
describe "#boolean_command or #boolean_array_command" do
|
|
79
|
+
it "returns true when string_command returns 'true'" do
|
|
80
|
+
client.stub(:string_command).with(:a_verb, :some_args).and_return("true")
|
|
81
|
+
client.boolean_command(:a_verb, :some_args).should == true
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "succeeds when given zero args" do
|
|
85
|
+
client.should_receive(:string_command).with(:a_verb, []).and_return("true")
|
|
86
|
+
client.boolean_command(:a_verb)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "returns false when string_command returns 'false'" do
|
|
90
|
+
client.stub(:string_command).with(:a_verb, :some_args).and_return("false")
|
|
91
|
+
client.boolean_command(:a_verb, :some_args).should == false
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it "returns an array of evaluated boolean values" do
|
|
95
|
+
client.stub(:string_array_command).with(:a_verb, :some_args).
|
|
96
|
+
and_return(["true", "false", "true", "true", "false"])
|
|
97
|
+
|
|
98
|
+
client.boolean_array_command(:a_verb, :some_args).should == [true, false, true, true, false]
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
describe "#http_request_for" do
|
|
103
|
+
it "returns cmd=verb for a verb" do
|
|
104
|
+
client.send(:http_request_for, "aCommand", []).should == "cmd=aCommand"
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it "escapes the command" do
|
|
108
|
+
client.send(:http_request_for, "a Command & More", []).should == "cmd=a+Command+%26+More"
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it "adds a session_id parameter when client has a current session id" do
|
|
112
|
+
client.stub(:session_id).and_return(24)
|
|
113
|
+
client.send(:http_request_for, "aCommand", []).should == "cmd=aCommand&sessionId=24"
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it "sets args as parameters whose key is their index" do
|
|
117
|
+
client.send(:http_request_for, "aCommand", [24, "foo", true]).should == "cmd=aCommand&1=24&2=foo&3=true"
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it "escapes arg values" do
|
|
121
|
+
client.send(:http_request_for, "aCommand", [ "This & That" ]).should == "cmd=aCommand&1=This+%26+That"
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
|
2
|
+
|
|
3
|
+
describe Selenium::Client::SeleniumHelper do
|
|
4
|
+
class SeleniumHelperClass
|
|
5
|
+
include Selenium::Client::SeleniumHelper
|
|
6
|
+
attr_accessor :selenium
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
let :object do
|
|
10
|
+
@object ||= (
|
|
11
|
+
o = SeleniumHelperClass.new
|
|
12
|
+
o.selenium = double("selenium")
|
|
13
|
+
|
|
14
|
+
o
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "delegates open to @selenium" do
|
|
19
|
+
object.selenium.should_receive(:open).with(:the_url).and_return(:the_result)
|
|
20
|
+
|
|
21
|
+
object.open(:the_url).should == :the_result
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "delegates type to @selenium" do
|
|
25
|
+
object.selenium.should_receive(:type).with(:the_locator, :the_value) \
|
|
26
|
+
.and_return(:the_result)
|
|
27
|
+
|
|
28
|
+
object.type(:the_locator, :the_value).should == :the_result
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "delegates select to @selenium" do
|
|
32
|
+
object.selenium.should_receive(:type).with(:the_input_locator,
|
|
33
|
+
:the_option_locator) \
|
|
34
|
+
.and_return(:the_result)
|
|
35
|
+
|
|
36
|
+
object.type(:the_input_locator, :the_option_locator).should == :the_result
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "delegates to any no-arg method defined on @selenium" do
|
|
40
|
+
object.selenium.should_receive(:a_noarg_method).with().and_return(:the_result)
|
|
41
|
+
|
|
42
|
+
object.a_noarg_method.should == :the_result
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "delegates to any arg method defined on @selenium" do
|
|
46
|
+
object.selenium.should_receive(:a_method).with(:alpha, :beta)\
|
|
47
|
+
.and_return(:the_result)
|
|
48
|
+
|
|
49
|
+
object.a_method(:alpha, :beta).should == :the_result
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "calls default method_missing when a method is not defined on @selenium" do
|
|
53
|
+
lambda { object.a_method(:alpha, :beta) }.should raise_error(NoMethodError)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'selenium-client'
|
|
2
|
+
require 'stringio'
|
|
3
|
+
|
|
4
|
+
# for bamboo
|
|
5
|
+
require 'ci/reporter/rspec'
|
|
6
|
+
|
|
7
|
+
module SeleniumClientSpecHelper
|
|
8
|
+
def capture_stderr(&blk)
|
|
9
|
+
io = StringIO.new
|
|
10
|
+
orig, $stderr = $stderr, io
|
|
11
|
+
|
|
12
|
+
begin
|
|
13
|
+
yield
|
|
14
|
+
ensure
|
|
15
|
+
$stderr = orig
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
io.string
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
RSpec.configure do |config|
|
|
23
|
+
config.include(SeleniumClientSpecHelper)
|
|
24
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require File.expand_path("../../webdriver/spec_helper", __FILE__)
|
|
2
|
+
require 'selenium/rake/server_task'
|
|
3
|
+
|
|
4
|
+
describe Selenium::Rake::ServerTask do
|
|
5
|
+
let(:mock_server) { double(Selenium::Server).as_null_object }
|
|
6
|
+
|
|
7
|
+
it "raises an error if no jar file is specified" do
|
|
8
|
+
lambda {
|
|
9
|
+
Selenium::Rake::ServerTask.new
|
|
10
|
+
}.should raise_error(Selenium::Rake::MissingJarFileError)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "launches the server with default options" do
|
|
14
|
+
expected_opts = {
|
|
15
|
+
:port => 4444,
|
|
16
|
+
:timeout => 30,
|
|
17
|
+
:background => true,
|
|
18
|
+
:log => true,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Selenium::Server.should_receive(:new).
|
|
22
|
+
with("selenium-server.jar", expected_opts).
|
|
23
|
+
and_return(mock_server)
|
|
24
|
+
|
|
25
|
+
task = Selenium::Rake::ServerTask.new { |t| t.jar = "selenium-server.jar" }
|
|
26
|
+
|
|
27
|
+
task.port.should == 4444
|
|
28
|
+
task.timeout.should == 30
|
|
29
|
+
task.background.should be_true
|
|
30
|
+
task.log.should be_true
|
|
31
|
+
task.opts.should == []
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "lets the user override the default options" do
|
|
35
|
+
expected_opts = {
|
|
36
|
+
:port => 5555,
|
|
37
|
+
:timeout => 120,
|
|
38
|
+
:background => false,
|
|
39
|
+
:log => false,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Selenium::Server.should_receive(:new).
|
|
43
|
+
with("selenium-server.jar", expected_opts).
|
|
44
|
+
and_return(mock_server)
|
|
45
|
+
|
|
46
|
+
task = Selenium::Rake::ServerTask.new { |t|
|
|
47
|
+
t.jar = "selenium-server.jar"
|
|
48
|
+
t.port = 5555
|
|
49
|
+
t.timeout = 120
|
|
50
|
+
t.background = false
|
|
51
|
+
t.log = false
|
|
52
|
+
|
|
53
|
+
t.opts << "-some" << "args"
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
task.port.should == 5555
|
|
57
|
+
task.timeout.should == 120
|
|
58
|
+
task.background.should be_false
|
|
59
|
+
task.log.should be_false
|
|
60
|
+
task.opts.should == ["-some", "args"]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "lets the user specify a version to use which it will automatically download" do
|
|
64
|
+
required_version = '10.2.0'
|
|
65
|
+
jar_file = "selenium-server-standalone-#{required_version}.jar"
|
|
66
|
+
|
|
67
|
+
Selenium::Server.should_receive(:new).
|
|
68
|
+
with(jar_file, anything()).
|
|
69
|
+
and_return(mock_server)
|
|
70
|
+
|
|
71
|
+
Selenium::Server.should_receive(:download).
|
|
72
|
+
with(required_version).
|
|
73
|
+
and_return(jar_file)
|
|
74
|
+
|
|
75
|
+
Selenium::Rake::ServerTask.new { |t| t.version = required_version }
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
end
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
require File.expand_path('../webdriver/spec_helper', __FILE__)
|
|
2
|
+
require 'selenium/server'
|
|
3
|
+
|
|
4
|
+
describe Selenium::Server do
|
|
5
|
+
let(:mock_process) { double(ChildProcess).as_null_object }
|
|
6
|
+
let(:mock_poller) { double("SocketPoller", :connected? => true, :closed? => true)}
|
|
7
|
+
|
|
8
|
+
it "raises an error if the jar file does not exist" do
|
|
9
|
+
lambda {
|
|
10
|
+
Selenium::Server.new("doesnt-exist.jar")
|
|
11
|
+
}.should raise_error(Errno::ENOENT)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "uses the given jar file and port" do
|
|
15
|
+
File.should_receive(:exist?).with("selenium-server-test.jar").and_return(true)
|
|
16
|
+
|
|
17
|
+
ChildProcess.should_receive(:build).
|
|
18
|
+
with("java", "-jar", "selenium-server-test.jar", "-port", "1234").
|
|
19
|
+
and_return(mock_process)
|
|
20
|
+
|
|
21
|
+
server = Selenium::Server.new("selenium-server-test.jar", :port => 1234, :background => true)
|
|
22
|
+
server.stub(:socket).and_return(mock_poller)
|
|
23
|
+
|
|
24
|
+
server.start
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "waits for the server process by default" do
|
|
28
|
+
File.should_receive(:exist?).with("selenium-server-test.jar").and_return(true)
|
|
29
|
+
|
|
30
|
+
ChildProcess.should_receive(:build).
|
|
31
|
+
with("java", "-jar", "selenium-server-test.jar", "-port", "4444").
|
|
32
|
+
and_return(mock_process)
|
|
33
|
+
|
|
34
|
+
server = Selenium::Server.new("selenium-server-test.jar")
|
|
35
|
+
server.stub(:socket).and_return(mock_poller)
|
|
36
|
+
|
|
37
|
+
mock_process.should_receive(:wait)
|
|
38
|
+
server.start
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "adds additional args" do
|
|
42
|
+
File.should_receive(:exist?).with("selenium-server-test.jar").and_return(true)
|
|
43
|
+
|
|
44
|
+
ChildProcess.should_receive(:build).
|
|
45
|
+
with("java", "-jar", "selenium-server-test.jar", "-port", "4444", "foo", "bar").
|
|
46
|
+
and_return(mock_process)
|
|
47
|
+
|
|
48
|
+
server = Selenium::Server.new("selenium-server-test.jar", :background => true)
|
|
49
|
+
server.stub(:socket).and_return(mock_poller)
|
|
50
|
+
|
|
51
|
+
server << ["foo", "bar"]
|
|
52
|
+
|
|
53
|
+
server.start
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "downloads the specified version from the selenium site" do
|
|
57
|
+
required_version = '10.2.0'
|
|
58
|
+
expected_download_file_name = "selenium-server-standalone-#{required_version}.jar"
|
|
59
|
+
|
|
60
|
+
stub_request(:get, "http://selenium.googlecode.com/files/#{expected_download_file_name}").to_return(:body => "this is pretending to be a jar file for testing purposes")
|
|
61
|
+
|
|
62
|
+
begin
|
|
63
|
+
actual_download_file_name = Selenium::Server.download(required_version)
|
|
64
|
+
actual_download_file_name.should == expected_download_file_name
|
|
65
|
+
File.should exist(expected_download_file_name)
|
|
66
|
+
ensure
|
|
67
|
+
FileUtils.rm_rf expected_download_file_name
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "gets a server instance and downloads the specified version" do
|
|
72
|
+
required_version = '10.4.0'
|
|
73
|
+
expected_download_file_name = "selenium-server-standalone-#{required_version}.jar"
|
|
74
|
+
expected_options = {:port => 5555}
|
|
75
|
+
fake_server = Object.new
|
|
76
|
+
|
|
77
|
+
Selenium::Server.should_receive(:download).with(required_version).and_return(expected_download_file_name)
|
|
78
|
+
Selenium::Server.should_receive(:new).with(expected_download_file_name, expected_options).and_return(fake_server)
|
|
79
|
+
server = Selenium::Server.get required_version, expected_options
|
|
80
|
+
server.should == fake_server
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "automatically repairs http_proxy settings that do not start with http://" do
|
|
84
|
+
with_env("http_proxy" => "proxy.com") do
|
|
85
|
+
Selenium::Server.net_http.proxy_address.should == 'proxy.com'
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
with_env("HTTP_PROXY" => "proxy.com") do
|
|
89
|
+
Selenium::Server.net_http.proxy_address.should == 'proxy.com'
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it "only downloads a jar if it is not present in the current directory" do
|
|
94
|
+
required_version = '10.2.0'
|
|
95
|
+
expected_download_file_name = "selenium-server-standalone-#{required_version}.jar"
|
|
96
|
+
|
|
97
|
+
File.should_receive(:exists?).with(expected_download_file_name).and_return true
|
|
98
|
+
|
|
99
|
+
Selenium::Server.download required_version
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "should know what the latest version available is" do
|
|
103
|
+
latest_version = '10.2.0'
|
|
104
|
+
stub_request(:get, "http://code.google.com/p/selenium/downloads/list").to_return(:body => "web page containing jar selenium-server-standalone-#{latest_version}.jar")
|
|
105
|
+
|
|
106
|
+
Selenium::Server.latest.should == latest_version
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it "should download the latest version if that has been specified" do
|
|
110
|
+
required_version = '10.6.0'
|
|
111
|
+
expected_download_file_name = "selenium-server-standalone-#{required_version}.jar"
|
|
112
|
+
|
|
113
|
+
Selenium::Server.should_receive(:latest).and_return required_version
|
|
114
|
+
stub_request(:get, "http://selenium.googlecode.com/files/#{expected_download_file_name}").to_return(:body => "this is pretending to be a jar file for testing purposes")
|
|
115
|
+
|
|
116
|
+
begin
|
|
117
|
+
actual_download_file_name = Selenium::Server.download(:latest)
|
|
118
|
+
actual_download_file_name.should == expected_download_file_name
|
|
119
|
+
File.should exist(expected_download_file_name)
|
|
120
|
+
ensure
|
|
121
|
+
FileUtils.rm_rf expected_download_file_name
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it "raises Selenium::Server::Error if the server is not launched within the timeout" do
|
|
126
|
+
File.should_receive(:exist?).with("selenium-server-test.jar").and_return(true)
|
|
127
|
+
|
|
128
|
+
poller = double('SocketPoller')
|
|
129
|
+
poller.should_receive(:connected?).and_return(false)
|
|
130
|
+
|
|
131
|
+
server = Selenium::Server.new("selenium-server-test.jar", :background => true)
|
|
132
|
+
server.stub(:socket).and_return(poller)
|
|
133
|
+
|
|
134
|
+
lambda { server.start }.should raise_error(Selenium::Server::Error)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it "sets options after instantiation" do
|
|
138
|
+
File.should_receive(:exist?).with("selenium-server-test.jar").and_return(true)
|
|
139
|
+
server = Selenium::Server.new("selenium-server-test.jar")
|
|
140
|
+
server.port.should == 4444
|
|
141
|
+
server.timeout.should == 30
|
|
142
|
+
server.background.should be_false
|
|
143
|
+
server.log.should be_nil
|
|
144
|
+
|
|
145
|
+
server.port = 1234
|
|
146
|
+
server.timeout = 5
|
|
147
|
+
server.background = true
|
|
148
|
+
server.log = "/tmp/server.log"
|
|
149
|
+
end
|
|
150
|
+
end
|