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,191 @@
|
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
|
2
|
+
|
|
3
|
+
describe "Element" do
|
|
4
|
+
|
|
5
|
+
it "should click" do
|
|
6
|
+
driver.navigate.to url_for("formPage.html")
|
|
7
|
+
driver.find_element(:id, "imageButton").click
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "should submit" do
|
|
11
|
+
driver.navigate.to url_for("formPage.html")
|
|
12
|
+
driver.find_element(:id, "submitButton").submit
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should send string keys" do
|
|
16
|
+
driver.navigate.to url_for("formPage.html")
|
|
17
|
+
driver.find_element(:id, "working").send_keys("foo", "bar")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
not_compliant_on :browser => [:android, :iphone, :safari] do
|
|
21
|
+
it "should send key presses" do
|
|
22
|
+
driver.navigate.to url_for("javascriptPage.html")
|
|
23
|
+
key_reporter = driver.find_element(:id, 'keyReporter')
|
|
24
|
+
|
|
25
|
+
key_reporter.send_keys("Tet", :arrow_left, "s")
|
|
26
|
+
key_reporter.attribute('value').should == "Test"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
not_compliant_on :browser => [:opera, :android, :iphone, :safari] do
|
|
31
|
+
it "should handle file uploads" do
|
|
32
|
+
driver.navigate.to url_for("formPage.html")
|
|
33
|
+
|
|
34
|
+
element = driver.find_element(:id, 'upload')
|
|
35
|
+
element.attribute('value').should be_empty
|
|
36
|
+
|
|
37
|
+
file = Tempfile.new('file-upload')
|
|
38
|
+
path = file.path
|
|
39
|
+
path.gsub!("/", "\\") if WebDriver::Platform.windows?
|
|
40
|
+
|
|
41
|
+
element.send_keys path
|
|
42
|
+
|
|
43
|
+
element.attribute('value').should include(File.basename(path))
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should get attribute value" do
|
|
48
|
+
driver.navigate.to url_for("formPage.html")
|
|
49
|
+
driver.find_element(:id, "withText").attribute("rows").should == "5"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "should return nil for non-existent attributes" do
|
|
53
|
+
driver.navigate.to url_for("formPage.html")
|
|
54
|
+
driver.find_element(:id, "withText").attribute("nonexistent").should be_nil
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "should clear" do
|
|
58
|
+
driver.navigate.to url_for("formPage.html")
|
|
59
|
+
driver.find_element(:id, "withText").clear
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
not_compliant_on :browser => :android do
|
|
63
|
+
it "should get and set selected" do
|
|
64
|
+
driver.navigate.to url_for("formPage.html")
|
|
65
|
+
|
|
66
|
+
cheese = driver.find_element(:id, "cheese")
|
|
67
|
+
peas = driver.find_element(:id, "peas")
|
|
68
|
+
|
|
69
|
+
cheese.click
|
|
70
|
+
|
|
71
|
+
cheese.should be_selected
|
|
72
|
+
peas.should_not be_selected
|
|
73
|
+
|
|
74
|
+
peas.click
|
|
75
|
+
|
|
76
|
+
peas.should be_selected
|
|
77
|
+
cheese.should_not be_selected
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "should get enabled" do
|
|
82
|
+
driver.navigate.to url_for("formPage.html")
|
|
83
|
+
driver.find_element(:id, "notWorking").should_not be_enabled
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "should get text" do
|
|
87
|
+
driver.navigate.to url_for("xhtmlTest.html")
|
|
88
|
+
driver.find_element(:class, "header").text.should == "XHTML Might Be The Future"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "should get displayed" do
|
|
92
|
+
driver.navigate.to url_for("xhtmlTest.html")
|
|
93
|
+
driver.find_element(:class, "header").should be_displayed
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it "should get location" do
|
|
97
|
+
driver.navigate.to url_for("xhtmlTest.html")
|
|
98
|
+
loc = driver.find_element(:class, "header").location
|
|
99
|
+
|
|
100
|
+
loc.x.should >= 1
|
|
101
|
+
loc.y.should >= 1
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
not_compliant_on :browser => [:iphone] do
|
|
105
|
+
it "should get location once scrolled into view" do
|
|
106
|
+
driver.navigate.to url_for("javascriptPage.html")
|
|
107
|
+
loc = driver.find_element(:id, 'keyUp').location_once_scrolled_into_view
|
|
108
|
+
|
|
109
|
+
loc.x.should >= 1
|
|
110
|
+
loc.y.should >= 0 # can be 0 if scrolled to the top
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it "should get size" do
|
|
115
|
+
driver.navigate.to url_for("xhtmlTest.html")
|
|
116
|
+
size = driver.find_element(:class, "header").size
|
|
117
|
+
|
|
118
|
+
size.width.should > 0
|
|
119
|
+
size.height.should > 0
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
compliant_on :driver => [:ie, :chrome] do # Firefox w/native events: issue 1771
|
|
123
|
+
it "should drag and drop" do
|
|
124
|
+
driver.navigate.to url_for("dragAndDropTest.html")
|
|
125
|
+
|
|
126
|
+
img1 = driver.find_element(:id, "test1")
|
|
127
|
+
img2 = driver.find_element(:id, "test2")
|
|
128
|
+
|
|
129
|
+
driver.action.drag_and_drop_by(img1, 100, 100).
|
|
130
|
+
drag_and_drop(img2, img1).
|
|
131
|
+
perform
|
|
132
|
+
|
|
133
|
+
img1.location.should == img2.location
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
not_compliant_on :browser => [:android] do # android returns 'green'
|
|
138
|
+
it "should get css property" do
|
|
139
|
+
driver.navigate.to url_for("javascriptPage.html")
|
|
140
|
+
element = driver.find_element(:id, "green-parent")
|
|
141
|
+
|
|
142
|
+
style1 = element.css_value("background-color")
|
|
143
|
+
style2 = element.style("background-color") # backwards compatibility
|
|
144
|
+
|
|
145
|
+
acceptable = ["rgb(0, 128, 0)", "#008000", 'rgba(0,128,0,1)', 'rgba(0, 128, 0, 1)']
|
|
146
|
+
acceptable.should include(style1, style2)
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
it "should know when two elements are equal" do
|
|
151
|
+
driver.navigate.to url_for("simpleTest.html")
|
|
152
|
+
|
|
153
|
+
body = driver.find_element(:tag_name, 'body')
|
|
154
|
+
xbody = driver.find_element(:xpath, "//body")
|
|
155
|
+
|
|
156
|
+
body.should == xbody
|
|
157
|
+
body.should eql(xbody)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
not_compliant_on :browser => :phantomjs do
|
|
161
|
+
it "should know when two elements are not equal" do
|
|
162
|
+
driver.navigate.to url_for("simpleTest.html")
|
|
163
|
+
|
|
164
|
+
elements = driver.find_elements(:tag_name, 'p')
|
|
165
|
+
p1 = elements.fetch(0)
|
|
166
|
+
p2 = elements.fetch(1)
|
|
167
|
+
|
|
168
|
+
p1.should_not == p2
|
|
169
|
+
p1.should_not eql(p2)
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
it "should return the same #hash for equal elements when found by Driver#find_element" do
|
|
174
|
+
driver.navigate.to url_for("simpleTest.html")
|
|
175
|
+
|
|
176
|
+
body = driver.find_element(:tag_name, 'body')
|
|
177
|
+
xbody = driver.find_element(:xpath, "//body")
|
|
178
|
+
|
|
179
|
+
body.hash.should == xbody.hash
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
it "should return the same #hash for equal elements when found by Driver#find_elements" do
|
|
183
|
+
driver.navigate.to url_for("simpleTest.html")
|
|
184
|
+
|
|
185
|
+
body = driver.find_elements(:tag_name, 'body').fetch(0)
|
|
186
|
+
xbody = driver.find_elements(:xpath, "//body").fetch(0)
|
|
187
|
+
|
|
188
|
+
body.hash.should == xbody.hash
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
|
2
|
+
|
|
3
|
+
describe Selenium::WebDriver::Error do
|
|
4
|
+
|
|
5
|
+
it "should raise an appropriate error" do
|
|
6
|
+
driver.navigate.to url_for("xhtmlTest.html")
|
|
7
|
+
|
|
8
|
+
lambda {
|
|
9
|
+
driver.find_element(:id, "nonexistant")
|
|
10
|
+
}.should raise_error(WebDriver::Error::NoSuchElementError)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
compliant_on :driver => [:remote, :firefox] do
|
|
14
|
+
it "should show stack trace information" do
|
|
15
|
+
driver.navigate.to url_for("xhtmlTest.html")
|
|
16
|
+
|
|
17
|
+
rescued = false
|
|
18
|
+
ex = nil
|
|
19
|
+
|
|
20
|
+
begin
|
|
21
|
+
driver.find_element(:id, "nonexistant")
|
|
22
|
+
rescue => ex
|
|
23
|
+
rescued = true
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
rescued.should be_true
|
|
27
|
+
ex.backtrace.first.should include("[remote server]")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Selenium
|
|
2
|
+
module WebDriver
|
|
3
|
+
module Firefox
|
|
4
|
+
|
|
5
|
+
describe Driver do
|
|
6
|
+
describe ".new" do
|
|
7
|
+
it "should take a Firefox::Profile instance as argument" do
|
|
8
|
+
begin
|
|
9
|
+
profile = Selenium::WebDriver::Firefox::Profile.new
|
|
10
|
+
driver = Selenium::WebDriver.for :firefox, :profile => profile
|
|
11
|
+
ensure
|
|
12
|
+
driver.quit if driver
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end # Firefox
|
|
19
|
+
end # WebDriver
|
|
20
|
+
end # Selenium
|
|
21
|
+
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
require File.expand_path("../../spec_helper", __FILE__)
|
|
2
|
+
|
|
3
|
+
module Selenium
|
|
4
|
+
module WebDriver
|
|
5
|
+
module Firefox
|
|
6
|
+
|
|
7
|
+
describe Profile do
|
|
8
|
+
let(:profile) { Profile.new }
|
|
9
|
+
|
|
10
|
+
def read_generated_prefs(from = nil)
|
|
11
|
+
prof = from || profile()
|
|
12
|
+
dir = prof.layout_on_disk
|
|
13
|
+
|
|
14
|
+
File.read(File.join(dir, 'user.js'))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should set additional preferences" do
|
|
18
|
+
profile['foo.number'] = 123
|
|
19
|
+
profile['foo.boolean'] = true
|
|
20
|
+
profile['foo.string'] = "bar"
|
|
21
|
+
|
|
22
|
+
string = read_generated_prefs
|
|
23
|
+
string.should include('user_pref("foo.number", 123)')
|
|
24
|
+
string.should include('user_pref("foo.boolean", true)')
|
|
25
|
+
string.should include(%{user_pref("foo.string", "bar")})
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should be serializable to JSON" do
|
|
29
|
+
profile['foo.boolean'] = true
|
|
30
|
+
|
|
31
|
+
new_profile = Profile.from_json(profile.to_json)
|
|
32
|
+
string = read_generated_prefs(new_profile)
|
|
33
|
+
string.should include('user_pref("foo.boolean", true)')
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should not let user override defaults" do
|
|
37
|
+
profile['app.update.enabled'] = true
|
|
38
|
+
|
|
39
|
+
string = read_generated_prefs
|
|
40
|
+
string.should include('user_pref("app.update.enabled", false)')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should properly handle escaped characters" do
|
|
44
|
+
profile['foo'] = 'C:\\r\\n'
|
|
45
|
+
|
|
46
|
+
string = read_generated_prefs
|
|
47
|
+
string.should include('user_pref("foo", "C:\\\\r\\\\n");')
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should let the user override some specific prefs" do
|
|
51
|
+
profile["browser.startup.page"] = "http://example.com"
|
|
52
|
+
|
|
53
|
+
string = read_generated_prefs
|
|
54
|
+
string.should include(%Q{user_pref("browser.startup.page", "http://example.com")})
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "should raise an error if the value given is not a string, number or boolean" do
|
|
58
|
+
lambda { profile['foo.bar'] = [] }.should raise_error(TypeError)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "should raise an error if the value is already stringified" do
|
|
62
|
+
lambda { profile['foo.bar'] = '"stringified"' }.should raise_error(ArgumentError)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "should enable secure SSL" do
|
|
66
|
+
profile.secure_ssl = true
|
|
67
|
+
|
|
68
|
+
string = read_generated_prefs
|
|
69
|
+
string.should include('user_pref("webdriver_accept_untrusted_certs", false)')
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "should disable secure SSL" do
|
|
73
|
+
profile.secure_ssl = false
|
|
74
|
+
|
|
75
|
+
string = read_generated_prefs
|
|
76
|
+
string.should include('user_pref("webdriver_accept_untrusted_certs", true)')
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "should change the setting for untrusted certificate issuer" do
|
|
80
|
+
profile.assume_untrusted_certificate_issuer = false
|
|
81
|
+
|
|
82
|
+
string = read_generated_prefs
|
|
83
|
+
string.should include('user_pref("webdriver_assume_untrusted_issuer", false)')
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "can configure a manual proxy" do
|
|
87
|
+
proxy = Proxy.new(
|
|
88
|
+
:http => "foo:123",
|
|
89
|
+
:ftp => "bar:234",
|
|
90
|
+
:ssl => "baz:345",
|
|
91
|
+
:no_proxy => "localhost"
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
profile.proxy = proxy
|
|
95
|
+
string = read_generated_prefs
|
|
96
|
+
|
|
97
|
+
string.should include('user_pref("network.proxy.http", "foo")')
|
|
98
|
+
string.should include('user_pref("network.proxy.http_port", 123)')
|
|
99
|
+
|
|
100
|
+
string.should include('user_pref("network.proxy.ftp", "bar")')
|
|
101
|
+
string.should include('user_pref("network.proxy.ftp_port", 234)')
|
|
102
|
+
|
|
103
|
+
string.should include('user_pref("network.proxy.ssl", "baz")')
|
|
104
|
+
string.should include('user_pref("network.proxy.ssl_port", 345)')
|
|
105
|
+
|
|
106
|
+
string.should include('user_pref("network.proxy.no_proxies_on", "localhost")')
|
|
107
|
+
string.should include('user_pref("network.proxy.type", 1)')
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it "can configure a PAC proxy" do
|
|
111
|
+
profile.proxy = Proxy.new(:pac => "http://foo/bar.pac")
|
|
112
|
+
string = read_generated_prefs
|
|
113
|
+
|
|
114
|
+
string.should include('user_pref("network.proxy.autoconfig_url", "http://foo/bar.pac")')
|
|
115
|
+
string.should include('user_pref("network.proxy.type", 2)')
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it "can configure an auto-detected proxy" do
|
|
119
|
+
profile.proxy = Proxy.new(:auto_detect => true)
|
|
120
|
+
string = read_generated_prefs
|
|
121
|
+
|
|
122
|
+
string.should include('user_pref("network.proxy.type", 4)')
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it "should be able to use the same profile more than once" do
|
|
126
|
+
profile['browser.startup.homepage'] = url_for("formPage.html")
|
|
127
|
+
|
|
128
|
+
begin
|
|
129
|
+
driver_one = WebDriver.for(:firefox, :profile => profile)
|
|
130
|
+
driver_two = WebDriver.for(:firefox, :profile => profile)
|
|
131
|
+
ensure
|
|
132
|
+
driver_one.quit if driver_one
|
|
133
|
+
driver_two.quit if driver_two
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
end
|
|
138
|
+
end # Firefox
|
|
139
|
+
end # WebDriver
|
|
140
|
+
end # Selenium
|
|
141
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
|
2
|
+
|
|
3
|
+
module Selenium
|
|
4
|
+
module WebDriver
|
|
5
|
+
describe Keyboard do
|
|
6
|
+
|
|
7
|
+
not_compliant_on :browser => [:chrome, :android, :iphone, :safari] do
|
|
8
|
+
it "sends keys to the active element" do
|
|
9
|
+
driver.navigate.to url_for("bodyTypingTest.html")
|
|
10
|
+
|
|
11
|
+
driver.keyboard.send_keys "ab"
|
|
12
|
+
|
|
13
|
+
text = driver.find_element(:id => "body_result").text.strip
|
|
14
|
+
text.should == "keypress keypress"
|
|
15
|
+
|
|
16
|
+
driver.find_element(:id => "result").text.strip.should be_empty
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "can send keys with shift pressed" do
|
|
20
|
+
driver.navigate.to url_for("javascriptPage.html")
|
|
21
|
+
|
|
22
|
+
event_input = driver.find_element(:id => "theworks")
|
|
23
|
+
keylogger = driver.find_element(:id => "result")
|
|
24
|
+
|
|
25
|
+
driver.mouse.click event_input
|
|
26
|
+
|
|
27
|
+
driver.keyboard.press :shift
|
|
28
|
+
driver.keyboard.send_keys "ab"
|
|
29
|
+
driver.keyboard.release :shift
|
|
30
|
+
|
|
31
|
+
event_input.attribute(:value).should == "AB"
|
|
32
|
+
keylogger.text.strip.should =~ /^(focus )?keydown keydown keypress keyup keydown keypress keyup keyup$/
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "raises an ArgumentError if the pressed key is not a modifier key" do
|
|
36
|
+
lambda { driver.keyboard.press :return }.should raise_error(ArgumentError)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "can press and release modifier keys" do
|
|
40
|
+
driver.navigate.to url_for("javascriptPage.html")
|
|
41
|
+
|
|
42
|
+
event_input = driver.find_element(:id => "theworks")
|
|
43
|
+
keylogger = driver.find_element(:id => "result")
|
|
44
|
+
|
|
45
|
+
driver.mouse.click event_input
|
|
46
|
+
|
|
47
|
+
driver.keyboard.press :shift
|
|
48
|
+
keylogger.text.should =~ /keydown$/
|
|
49
|
+
|
|
50
|
+
driver.keyboard.release :shift
|
|
51
|
+
keylogger.text.should =~ /keyup$/
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end # Keyboard
|
|
56
|
+
end # WebDriver
|
|
57
|
+
end # Selenium
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
|
2
|
+
|
|
3
|
+
module Selenium::WebDriver::DriverExtensions
|
|
4
|
+
describe HasLocation do
|
|
5
|
+
|
|
6
|
+
let(:lat) { 40.714353 }
|
|
7
|
+
let(:lon) { -74.005973 }
|
|
8
|
+
let(:alt) { 0.056747 }
|
|
9
|
+
|
|
10
|
+
let(:location) {
|
|
11
|
+
Selenium::WebDriver::Location.new lat, lon, alt
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
compliant_on :browser => [:iphone, :android] do
|
|
15
|
+
it "can get and set location" do
|
|
16
|
+
driver.manage.timeouts.implicit_wait = 2
|
|
17
|
+
driver.navigate.to url_for("html5Page.html")
|
|
18
|
+
|
|
19
|
+
driver.location = location
|
|
20
|
+
loc = driver.location
|
|
21
|
+
|
|
22
|
+
loc.latitude.should be_within(0.000001).of(lat)
|
|
23
|
+
loc.longitude.should be_within(0.000001).of(lon)
|
|
24
|
+
loc.altitude.should be_within(0.000001).of(alt)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|