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,500 @@
|
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
|
2
|
+
|
|
3
|
+
describe Selenium::Client::Idiomatic do
|
|
4
|
+
class IdiomaticClient
|
|
5
|
+
include Selenium::Client::Idiomatic
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
let(:client) { IdiomaticClient.new }
|
|
9
|
+
|
|
10
|
+
it "has #text is an alias for get_text" do
|
|
11
|
+
client.should_receive(:string_command).with("getText", [:the_locator,]).and_return(:the_text)
|
|
12
|
+
client.text(:the_locator).should == :the_text
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "#title returns the result of the getTitle command" do
|
|
16
|
+
client.should_receive(:string_command).with("getTitle").and_return(:the_title)
|
|
17
|
+
client.title.should == :the_title
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "#location returns the result of the getLocation command" do
|
|
21
|
+
client.should_receive(:string_command).with("getLocation").and_return(:the_location)
|
|
22
|
+
client.location.should == :the_location
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe "#wait_for_page" do
|
|
26
|
+
it "waits for a page to load, converting seconds timeout to milliseconds" do
|
|
27
|
+
client.should_receive(:remote_control_command).with("waitForPageToLoad", [2000,])
|
|
28
|
+
client.wait_for_page 2
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "waits for a page to load with the default timeout when none is specified" do
|
|
32
|
+
client.should_receive(:remote_control_command).with("waitForPageToLoad", [7000,])
|
|
33
|
+
client.stub(:default_timeout_in_seconds).and_return(7)
|
|
34
|
+
client.wait_for_page
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "waits for a page to load with a string timeout for backward compatibility" do
|
|
38
|
+
client.should_receive(:remote_control_command).with("waitForPageToLoad", [2000,])
|
|
39
|
+
client.wait_for_page "2"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "has #wait_for_page_to_load as an alias providing easy transition to people used to the old API" do
|
|
43
|
+
client.should_receive(:remote_control_command).with("waitForPageToLoad", [24000,])
|
|
44
|
+
client.wait_for_page_to_load 24
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe "#wait_for_popup" do
|
|
49
|
+
it "returns the result of the waitForPopUp command" do
|
|
50
|
+
client.should_receive(:remote_control_command).with("waitForPopUp", [:the_window_id, 0]).and_return(:the_value)
|
|
51
|
+
client.wait_for_popup(:the_window_id, 0).should == :the_value
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "converts the timeout from seconds to milliseconds" do
|
|
55
|
+
client.should_receive(:remote_control_command).with("waitForPopUp", [:the_window_id, 3000]).and_return(:the_value)
|
|
56
|
+
client.wait_for_popup(:the_window_id, 3).should == :the_value
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "accepts timeout as a string for backward compatibility" do
|
|
60
|
+
client.should_receive(:remote_control_command).with("waitForPopUp", [:the_window_id, 5000]).and_return(:the_value)
|
|
61
|
+
client.wait_for_popup(:the_window_id, "5").should == :the_value
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "uses the default timeout when none is specified" do
|
|
65
|
+
client.should_receive(:remote_control_command).with("waitForPopUp", [:the_window_id, 7000]).and_return(:the_value)
|
|
66
|
+
client.stub(:default_timeout_in_seconds).and_return(7)
|
|
67
|
+
client.wait_for_popup :the_window_id
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe "#wait_for_condition" do
|
|
72
|
+
it "waits for a page to load using the default timeout when none is specified" do
|
|
73
|
+
client.should_receive(:remote_control_command).with("waitForCondition", ["some javascript", 7000,])
|
|
74
|
+
client.stub(:default_timeout_in_seconds).and_return(7)
|
|
75
|
+
client.wait_for_condition "some javascript"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "waits for a page to load using the given timeout converted to milliseconds" do
|
|
79
|
+
client.should_receive(:remote_control_command).with("waitForCondition", ["some javascript", 24000,])
|
|
80
|
+
client.stub(:default_timeout_in_seconds).and_return(7)
|
|
81
|
+
client.wait_for_condition "some javascript", 24
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "accepts timeout as a string for backward compatibility" do
|
|
85
|
+
client.should_receive(:remote_control_command).with("waitForCondition", ["some javascript", 64000,])
|
|
86
|
+
client.stub(:default_timeout_in_seconds).and_return(7)
|
|
87
|
+
client.wait_for_condition "some javascript", "64"
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
describe "#wait_for" do
|
|
92
|
+
it "does nothing when no options are given" do
|
|
93
|
+
client.should_receive(:remote_control_command).never
|
|
94
|
+
client.wait_for({})
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "waits for page with explicit timeout when one is provided" do
|
|
98
|
+
client.should_receive(:wait_for_page).with(:the_timeout)
|
|
99
|
+
client.wait_for :wait_for => :page, :timeout_in_seconds => :the_timeout
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "waits for ajax to complete when ajax option is provided" do
|
|
103
|
+
client.should_receive(:wait_for_ajax)
|
|
104
|
+
client.wait_for :wait_for => :ajax
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it "waits for ajax using the given javascript framework override" do
|
|
108
|
+
client.should_receive(:wait_for_ajax).with(hash_including(:javascript_framework => :jquery))
|
|
109
|
+
client.wait_for :wait_for => :ajax, :javascript_framework => :jquery
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "waits for ajax with explicit timeout when one is provided" do
|
|
113
|
+
client.should_receive(:wait_for_ajax).with(hash_including(:timeout_in_seconds => :the_timeout))
|
|
114
|
+
client.wait_for :wait_for => :ajax, :timeout_in_seconds => :the_timeout
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it "waits for element to be present when element option is provided" do
|
|
118
|
+
client.should_receive(:wait_for_element).with(:the_new_element_id, anything)
|
|
119
|
+
client.wait_for :wait_for => :element, :element => :the_new_element_id
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it "waits for element with explicit timeout when one is provided" do
|
|
123
|
+
client.should_receive(:wait_for_element).with(:the_new_element_id, hash_including(:timeout_in_seconds => :the_timeout))
|
|
124
|
+
client.wait_for :wait_for => :element, :element => :the_new_element_id,
|
|
125
|
+
:timeout_in_seconds => :the_timeout
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it "waits for no element to be present when no_element option is provided" do
|
|
129
|
+
client.should_receive(:wait_for_no_element).with(:the_new_element_id, hash_including(:element => :the_new_element_id))
|
|
130
|
+
client.wait_for :wait_for => :no_element, :element => :the_new_element_id
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it "waits for no element with explicit timeout when one is provided" do
|
|
134
|
+
client.should_receive(:wait_for_no_element).with(:the_new_element_id, hash_including(:element => :the_new_element_id, :timeout_in_seconds => :the_timeout))
|
|
135
|
+
client.wait_for :wait_for => :no_element, :element => :the_new_element_id,
|
|
136
|
+
:timeout_in_seconds => :the_timeout
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it "waits for text to be present when text option is provided" do
|
|
140
|
+
client.should_receive(:wait_for_text).with("some text", hash_including(:element => "a locator", :text => "some text"))
|
|
141
|
+
client.wait_for :wait_for => :text, :element => "a locator", :text => "some text"
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
it "waits for text with explicit timeout when one is provided" do
|
|
145
|
+
client.should_receive(:wait_for_text).with("some text", hash_including(:timeout_in_seconds => :the_timeout))
|
|
146
|
+
client.wait_for :wait_for => :text,
|
|
147
|
+
:text => "some text",
|
|
148
|
+
:timeout_in_seconds => :the_timeout
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it "waits for text to NOT be present when no_text option is provided" do
|
|
152
|
+
client.should_receive(:wait_for_no_text).with("some text", hash_including(:element => 'a_locator'))
|
|
153
|
+
client.wait_for :wait_for => :no_text, :element => 'a_locator', :text => "some text"
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
it "waits for no text with explicit timeout and locator when none are provided" do
|
|
157
|
+
client.should_receive(:wait_for_no_text).with("some text", hash_including(:timeout_in_seconds => :the_timeout))
|
|
158
|
+
client.wait_for :wait_for => :no_text, :text => "some text",
|
|
159
|
+
:timeout_in_seconds => :the_timeout
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
it "waits for effects to complete when effects option is provided" do
|
|
163
|
+
client.should_receive(:wait_for_effects)
|
|
164
|
+
client.wait_for :wait_for => :effects
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
it "waits for effects with explicit timeout when one is provided" do
|
|
168
|
+
client.should_receive(:wait_for_effects).with(hash_including(:timeout_in_seconds => :the_timeout))
|
|
169
|
+
client.wait_for :wait_for => :effects, :timeout_in_seconds => :the_timeout
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
it "waits for effects using the given javascript framework override" do
|
|
173
|
+
client.should_receive(:wait_for_effects).with(hash_including(:javascript_framework => :jquery))
|
|
174
|
+
client.wait_for :wait_for => :effects, :javascript_framework => :jquery
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
it "waits for popup to appear when popup option is provided" do
|
|
178
|
+
client.should_receive(:wait_for_popup).with(:the_window_id, nil)
|
|
179
|
+
client.wait_for :wait_for => :popup, :window => :the_window_id
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
it "waits for popup with explicit timeout when provided" do
|
|
183
|
+
client.should_receive(:wait_for_popup).with(:the_window_id, :the_timeout)
|
|
184
|
+
client.wait_for :wait_for => :popup, :window => :the_window_id, :timeout_in_seconds => :the_timeout
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
it "selects the popup when the select option is true" do
|
|
188
|
+
client.should_receive(:wait_for_popup).with(:the_window_id, nil)
|
|
189
|
+
client.should_receive(:select_window).with(:the_window_id)
|
|
190
|
+
client.wait_for :wait_for => :popup, :window => :the_window_id, :select => true
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
it "does not select the popup when the select option is false" do
|
|
194
|
+
client.should_receive(:wait_for_popup).with(:the_window_id, nil)
|
|
195
|
+
client.should_receive(:select_window).with(:the_window_id).never
|
|
196
|
+
client.wait_for :wait_for => :popup, :window => :the_window_id
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
it "waits for field value when value option is provided" do
|
|
200
|
+
client.should_receive(:wait_for_field_value).with(:the_locator, :expected_value, anything)
|
|
201
|
+
client.wait_for :wait_for => :value, :element => :the_locator, :value => :expected_value
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
it "waits for field using explicit timeout when provided" do
|
|
205
|
+
client.should_receive(:wait_for_field_value).with(:the_locator, :expected_value,
|
|
206
|
+
hash_including(:timeout_in_seconds => :the_timeout))
|
|
207
|
+
|
|
208
|
+
client.wait_for :wait_for => :value, :element => :the_locator,
|
|
209
|
+
:value => :expected_value,
|
|
210
|
+
:timeout_in_seconds => :the_timeout
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
it "waits for no field value when value option is provided" do
|
|
214
|
+
client.should_receive(:wait_for_no_field_value).with(:the_locator, :expected_value, anything)
|
|
215
|
+
client.wait_for :wait_for => :no_value, :element => :the_locator, :value => :expected_value
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it "waits for no field value using explicit timeout when provided" do
|
|
219
|
+
client.should_receive(:wait_for_no_field_value).with(:the_locator,
|
|
220
|
+
:expected_value,
|
|
221
|
+
hash_including(:timeout_in_seconds => :the_timeout))
|
|
222
|
+
client.wait_for :wait_for => :no_value, :element => :the_locator,
|
|
223
|
+
:value => :expected_value,
|
|
224
|
+
:timeout_in_seconds => :the_timeout
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
it "waits for element to be visible when visible option is provided" do
|
|
228
|
+
client.should_receive(:wait_for_visible).with(:the_locator, anything)
|
|
229
|
+
client.wait_for :wait_for => :visible, :element => :the_locator, :value => :expected_value
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
it "waits for element to be visible using explicit timeout when provided" do
|
|
233
|
+
client.should_receive(:wait_for_visible).with(:the_locator,
|
|
234
|
+
hash_including(:timeout_in_seconds => :the_timeout))
|
|
235
|
+
client.wait_for :wait_for => :visible, :element => :the_locator,
|
|
236
|
+
:timeout_in_seconds => :the_timeout
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
it "waits for element to not be visible when visible option is provided" do
|
|
240
|
+
client.should_receive(:wait_for_not_visible).with(:the_locator, anything)
|
|
241
|
+
client.wait_for :wait_for => :not_visible, :element => :the_locator, :value => :expected_value
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
it "waits for element to not be visible using explicit timeout when provided" do
|
|
245
|
+
client.should_receive(:wait_for_not_visible).with(:the_locator,
|
|
246
|
+
hash_including(:timeout_in_seconds => :the_timeout))
|
|
247
|
+
client.wait_for :wait_for => :not_visible, :element => :the_locator,
|
|
248
|
+
:timeout_in_seconds => :the_timeout
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
it "waits for given javascript to return true when condition option is provided" do
|
|
252
|
+
client.should_receive(:wait_for_condition).with("some javascript", nil)
|
|
253
|
+
client.wait_for :wait_for => :condition, :javascript => "some javascript"
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
describe "#body_text" do
|
|
258
|
+
it "returns the result of the getBodyText command" do
|
|
259
|
+
client.should_receive(:string_command).with("getBodyText").and_return(:the_text)
|
|
260
|
+
client.body_text.should == :the_text
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
describe "#click" do
|
|
265
|
+
it "clicks on an element when no options are given" do
|
|
266
|
+
client.should_receive(:remote_control_command).with("click", [:the_locator,])
|
|
267
|
+
client.click :the_locator
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
it "calls wait_for with options provided" do
|
|
271
|
+
client.should_receive(:remote_control_command).with("click", [:the_locator,])
|
|
272
|
+
client.should_receive(:wait_for).with(:wait_for => :page)
|
|
273
|
+
client.click :the_locator, :wait_for => :page
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
describe "#value" do
|
|
278
|
+
it "value returns the result of the getValue command" do
|
|
279
|
+
client.should_receive(:string_command).with("getValue", [:the_locator,]).and_return(:the_value)
|
|
280
|
+
client.value(:the_locator).should == :the_value
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
describe "#field" do
|
|
285
|
+
it "field returns the result of the getValue command" do
|
|
286
|
+
client.should_receive(:string_command).with("getValue", [:the_locator,]).and_return(:the_value)
|
|
287
|
+
client.field(:the_locator).should == :the_value
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
describe "#checked?" do
|
|
292
|
+
it "checked? returns the result of the isChecked command" do
|
|
293
|
+
client.should_receive(:boolean_command).with("isChecked", [:the_locator,]).and_return(:the_value)
|
|
294
|
+
client.checked?(:the_locator).should == :the_value
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
describe "#text?" do
|
|
299
|
+
it "returns the result of the isTextPresent command" do
|
|
300
|
+
client.should_receive(:boolean_command).with("isTextPresent", [:the_pattern,]).and_return(:the_result)
|
|
301
|
+
client.text?(:the_pattern).should == :the_result
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
describe "#element?" do
|
|
306
|
+
it "returns the result of the isElementPresent command" do
|
|
307
|
+
client.should_receive(:boolean_command).with("isElementPresent", [:the_locator,]).and_return(:the_result)
|
|
308
|
+
client.element?(:the_locator).should == :the_result
|
|
309
|
+
end
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
describe "visible?" do
|
|
313
|
+
it "returns the result of the isTextPresent command" do
|
|
314
|
+
client.should_receive(:boolean_command).with("isVisible", [:the_locator,]).and_return(:the_result)
|
|
315
|
+
client.visible?(:the_locator).should == :the_result
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
describe "#alert? or #alert" do
|
|
320
|
+
it "returns the result of the isAlertPresent command" do
|
|
321
|
+
client.should_receive(:boolean_command).with("isAlertPresent").and_return(:the_result)
|
|
322
|
+
client.alert?.should == :the_result
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
it "returns the result of the getAlert command" do
|
|
326
|
+
client.should_receive(:string_command).with("getAlert").and_return(:the_result)
|
|
327
|
+
client.alert.should == :the_result
|
|
328
|
+
end
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
describe "#confirmation? or #confirmation" do
|
|
332
|
+
it "returns the result of the isConfirmationPresent command" do
|
|
333
|
+
client.should_receive(:boolean_command).with("isConfirmationPresent").and_return(:the_result)
|
|
334
|
+
client.confirmation?.should == :the_result
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
it "returns the result of the getConfirmation command" do
|
|
338
|
+
client.should_receive(:string_command).with("getConfirmation").and_return(:the_result)
|
|
339
|
+
client.confirmation.should == :the_result
|
|
340
|
+
end
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
describe "#prompt? and #prompt" do
|
|
344
|
+
it "prompt? returns the result of the isPromptPresent command" do
|
|
345
|
+
client.should_receive(:boolean_command).with("isPromptPresent").and_return(:the_result)
|
|
346
|
+
client.prompt?.should == :the_result
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
it "prompt returns the result of the getPrompt command" do
|
|
350
|
+
client.should_receive(:string_command).with("getPrompt").and_return(:the_result)
|
|
351
|
+
client.prompt.should == :the_result
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
it "prompt returns the result of the getEval command" do
|
|
355
|
+
client.should_receive(:string_command).with("getEval", [:the_script,]).and_return(:the_result)
|
|
356
|
+
client.js_eval(:the_script).should == :the_result
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
describe "table_cell_text" do
|
|
361
|
+
it "table_cell_text returns the result of the getTable command" do
|
|
362
|
+
client.should_receive(:string_command).with("getTable", [:the_cell_address,]).and_return(:the_value)
|
|
363
|
+
client.table_cell_text(:the_cell_address).should == :the_value
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
describe "#cookies, #cookie, #cookie?" do
|
|
368
|
+
it "returns the result of the getCookie command" do
|
|
369
|
+
client.should_receive(:string_command).with("getCookie").and_return(:the_value)
|
|
370
|
+
client.cookies.should == :the_value
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
it "returns the result of the getCookieByName command" do
|
|
374
|
+
client.should_receive(:string_command).with("getCookieByName", [:the_name,]).and_return(:the_value)
|
|
375
|
+
client.cookie(:the_name).should == :the_value
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
it "returns the result of the isCookiePresent command" do
|
|
379
|
+
client.should_receive(:boolean_command).with("isCookiePresent", [:the_name,]).and_return(:the_value)
|
|
380
|
+
client.cookie?(:the_name).should == :the_value
|
|
381
|
+
end
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
describe "#create_cookie" do
|
|
385
|
+
|
|
386
|
+
it "returns the result of the createCookie command" do
|
|
387
|
+
client.should_receive(:remote_control_command).with("createCookie", [:the_name_value_pair, "options"]).and_return(:the_value)
|
|
388
|
+
client.create_cookie(:the_name_value_pair, "options").should == :the_value
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
it "returns the result of the createCookie command when no options are given" do
|
|
392
|
+
client.should_receive(:remote_control_command).with("createCookie", [:the_name_value_pair, ""]).and_return(:the_value)
|
|
393
|
+
client.create_cookie(:the_name_value_pair).should == :the_value
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
it "converts hash options to cookie strings" do
|
|
397
|
+
client.should_receive(:remote_control_command).with do |cmd, args|
|
|
398
|
+
cmd.should == "createCookie"
|
|
399
|
+
|
|
400
|
+
args.size.should == 2
|
|
401
|
+
args.first.should == :the_name_value_pair
|
|
402
|
+
[ "max_age=60, domain=.foo.com",
|
|
403
|
+
"domain=.foo.com, max_age=60" ].should include(args.last)
|
|
404
|
+
end.and_return(:the_value)
|
|
405
|
+
|
|
406
|
+
result = client.create_cookie(:the_name_value_pair, {:max_age => 60, :domain => ".foo.com"})
|
|
407
|
+
result.should == :the_value
|
|
408
|
+
end
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
describe "#delete_cookie" do
|
|
412
|
+
it "returns the result of the createCookie command" do
|
|
413
|
+
client.should_receive(:remote_control_command).with("deleteCookie", [:the_name, "options"]).and_return(:the_value)
|
|
414
|
+
client.delete_cookie(:the_name, "options").should == :the_value
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
it "options are optional for delete_cookie when no options are given" do
|
|
418
|
+
client.should_receive(:remote_control_command).with("deleteCookie", [:the_name, ""]).and_return(:the_value)
|
|
419
|
+
client.delete_cookie(:the_name).should == :the_value
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
it "converts hash options to cookie strings" do
|
|
423
|
+
client.should_receive(:remote_control_command).with("deleteCookie", [:the_name, "domain=.foo.com, max_age=60"]).and_return(:the_value)
|
|
424
|
+
result = client.delete_cookie(:the_name, {:max_age => 60, :domain => ".foo.com"})
|
|
425
|
+
result.should == :the_value
|
|
426
|
+
end
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
describe "#all_window_ids, #all_window_titles or #all_window_names" do
|
|
430
|
+
it "returns the result of the getAllWindowIds command" do
|
|
431
|
+
client.should_receive(:string_array_command).with("getAllWindowIds").and_return(:the_value)
|
|
432
|
+
client.all_window_ids.should == :the_value
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
it "returns the result of the getAllWindowNames command" do
|
|
436
|
+
client.should_receive(:string_array_command).with("getAllWindowNames").and_return(:the_value)
|
|
437
|
+
client.all_window_names.should == :the_value
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
it "returns the result of the getAllWindowTitles command" do
|
|
441
|
+
client.should_receive(:string_array_command).with("getAllWindowTitles").and_return(:the_value)
|
|
442
|
+
client.all_window_titles.should == :the_value
|
|
443
|
+
end
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
describe "#browser_network_traffic" do
|
|
447
|
+
it "returns the result of the captureNetworkTraffic command" do
|
|
448
|
+
client.should_receive(:remote_control_command).with("captureNetworkTraffic", ["json"]).and_return(:the_value)
|
|
449
|
+
client.browser_network_traffic(:json).should == :the_value
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
it "uses plain as the default format" do
|
|
453
|
+
client.should_receive(:remote_control_command).with("captureNetworkTraffic", ["plain"]).and_return(:the_value)
|
|
454
|
+
client.browser_network_traffic.should == :the_value
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
it "raises a RuntimeError when format is nil" do
|
|
458
|
+
lambda { client.browser_network_traffic(nil) }.should raise_error(RuntimeError)
|
|
459
|
+
end
|
|
460
|
+
|
|
461
|
+
it "raises a RuntimeError when format is an unknown format" do
|
|
462
|
+
lambda { client.browser_network_traffic(:random_format) }.should raise_error(RuntimeError)
|
|
463
|
+
end
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
describe "#browser_xpath_library=" do
|
|
467
|
+
it "invokes the useXpathLibrary command" do
|
|
468
|
+
client.should_receive(:remote_control_command).with("useXpathLibrary", ["ajaxslt"]).and_return(:the_value)
|
|
469
|
+
client.browser_xpath_library = :ajaxslt
|
|
470
|
+
end
|
|
471
|
+
|
|
472
|
+
it "raises a RuntimeError whe library name is unknown" do
|
|
473
|
+
lambda { client.browser_xpath_library = :random_library }.should raise_error(RuntimeError)
|
|
474
|
+
end
|
|
475
|
+
end
|
|
476
|
+
|
|
477
|
+
describe "#highlight_located_element=" do
|
|
478
|
+
it "setting highlight_located_element to true enables auto-hilighting in selenium core" do
|
|
479
|
+
client.should_receive(:js_eval).with("selenium.browserbot.shouldHighlightLocatedElement = true")
|
|
480
|
+
client.highlight_located_element = true
|
|
481
|
+
end
|
|
482
|
+
|
|
483
|
+
it "setting highlight_located_element to false disables auto-hilighting in selenium core" do
|
|
484
|
+
client.should_receive(:js_eval).with("selenium.browserbot.shouldHighlightLocatedElement = false")
|
|
485
|
+
client.highlight_located_element = false
|
|
486
|
+
end
|
|
487
|
+
end
|
|
488
|
+
|
|
489
|
+
describe "#execution_delay or #execution_delay=" do
|
|
490
|
+
it "execution_delay returns the result of the getSpeed command" do
|
|
491
|
+
client.should_receive(:string_command).with("getSpeed").and_return(:the_speed)
|
|
492
|
+
client.execution_delay.should == :the_speed
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
it "execution_delay= executes the setSpeed command" do
|
|
496
|
+
client.should_receive(:remote_control_command).with("setSpeed", [24])
|
|
497
|
+
client.execution_delay= 24
|
|
498
|
+
end
|
|
499
|
+
end
|
|
500
|
+
end
|