|
25 | 25 | expect(driver.title).to eq("XHTML Test Page")
|
26 | 26 | end
|
27 | 27 |
|
28 |
| - # Edge does not yet support {GET} /session/{sessionId}/Source |
29 |
| - not_compliant_on :browser => :edge do |
30 |
| - it "should get the page source" do |
31 |
| - driver.navigate.to url_for("xhtmlTest.html") |
32 |
| - expect(driver.page_source).to match(%r[<title>XHTML Test Page</title>]i) |
33 |
| - end |
| 28 | + it "should get the page source" do |
| 29 | + driver.navigate.to url_for("xhtmlTest.html") |
| 30 | + expect(driver.page_source).to match(%r[<title>XHTML Test Page</title>]i) |
34 | 31 | end
|
35 | 32 |
|
36 | 33 | not_compliant_on :browser => :safari do
|
|
108 | 105 | expect(driver.find_element(:tag_name, 'div').attribute("class")).to eq("navigation")
|
109 | 106 | end
|
110 | 107 |
|
111 |
| - # Edge does not yet support {POST} /session/{sessionId}/element/{elementId}/element |
112 |
| - not_compliant_on :browser => :edge do |
113 |
| - it "should find child element" do |
114 |
| - driver.navigate.to url_for("nestedElements.html") |
| 108 | + it "should find child element" do |
| 109 | + driver.navigate.to url_for("nestedElements.html") |
115 | 110 |
|
116 |
| - element = driver.find_element(:name, "form2") |
117 |
| - child = element.find_element(:name, "selectomatic") |
| 111 | + element = driver.find_element(:name, "form2") |
| 112 | + child = element.find_element(:name, "selectomatic") |
118 | 113 |
|
119 |
| - expect(child.attribute("id")).to eq("2") |
120 |
| - end |
| 114 | + expect(child.attribute("id")).to eq("2") |
121 | 115 | end
|
122 | 116 |
|
123 |
| - # Edge does not yet support {POST} /session/{sessionId}/element/{elementId}/elements |
124 |
| - not_compliant_on :browser => :edge do |
125 |
| - it "should find child element by tag name" do |
126 |
| - driver.navigate.to url_for("nestedElements.html") |
| 117 | + it "should find child element by tag name" do |
| 118 | + driver.navigate.to url_for("nestedElements.html") |
127 | 119 |
|
128 |
| - element = driver.find_element(:name, "form2") |
129 |
| - child = element.find_element(:tag_name, "select") |
| 120 | + element = driver.find_element(:name, "form2") |
| 121 | + child = element.find_element(:tag_name, "select") |
130 | 122 |
|
131 |
| - expect(child.attribute("id")).to eq("2") |
132 |
| - end |
| 123 | + expect(child.attribute("id")).to eq("2") |
133 | 124 | end
|
134 | 125 |
|
135 | 126 | it "should raise on nonexistant element" do
|
|
161 | 152 | driver.find_elements(:css, 'p')
|
162 | 153 | end
|
163 | 154 |
|
164 |
| - # Edge does not yet support {POST} /session/{sessionId}/element/{elementId}/elements |
165 |
| - not_compliant_on :browser => :edge do |
166 |
| - it "should find children by field name" do |
167 |
| - driver.navigate.to url_for("nestedElements.html") |
168 |
| - element = driver.find_element(:name, "form2") |
169 |
| - children = element.find_elements(:name, "selectomatic") |
170 |
| - expect(children.size).to eq(2) |
171 |
| - end |
| 155 | + it "should find children by field name" do |
| 156 | + driver.navigate.to url_for("nestedElements.html") |
| 157 | + element = driver.find_element(:name, "form2") |
| 158 | + children = element.find_elements(:name, "selectomatic") |
| 159 | + expect(children.size).to eq(2) |
172 | 160 | end
|
173 | 161 | end
|
174 | 162 |
|
175 |
| - describe "execute script" do |
176 |
| - it "should return strings" do |
177 |
| - driver.navigate.to url_for("xhtmlTest.html") |
178 |
| - expect(driver.execute_script("return document.title;")).to eq("XHTML Test Page") |
179 |
| - end |
180 |
| - |
181 |
| - it "should return numbers" do |
182 |
| - driver.navigate.to url_for("xhtmlTest.html") |
183 |
| - expect(driver.execute_script("return document.title.length;")).to eq("XHTML Test Page".length) |
184 |
| - end |
| 163 | + describe "execute script" do |
| 164 | + it "should return strings" do |
| 165 | + driver.navigate.to url_for("xhtmlTest.html") |
| 166 | + expect(driver.execute_script("return document.title;")).to eq("XHTML Test Page") |
| 167 | + end |
185 | 168 |
|
186 |
| - it "should return elements" do |
187 |
| - driver.navigate.to url_for("xhtmlTest.html") |
188 |
| - element = driver.execute_script("return document.getElementById('id1');") |
189 |
| - expect(element).to be_kind_of(WebDriver::Element) |
190 |
| - expect(element.text).to eq("Foo") |
191 |
| - end |
| 169 | + it "should return numbers" do |
| 170 | + driver.navigate.to url_for("xhtmlTest.html") |
| 171 | + expect(driver.execute_script("return document.title.length;")).to eq("XHTML Test Page".length) |
| 172 | + end |
192 | 173 |
|
193 |
| - not_compliant_on :browser => [:android] do |
194 |
| - it "should unwrap elements in deep objects" do |
195 |
| - driver.navigate.to url_for("xhtmlTest.html") |
196 |
| - result = driver.execute_script(<<-SCRIPT) |
197 |
| - var e1 = document.getElementById('id1'); |
198 |
| - var body = document.body; |
199 |
| -
|
200 |
| - return { |
201 |
| - elements: {'body' : body, other: [e1] } |
202 |
| - }; |
203 |
| - SCRIPT |
204 |
| - |
205 |
| - expect(result).to be_kind_of(Hash) |
206 |
| - expect(result['elements']['body']).to be_kind_of(WebDriver::Element) |
207 |
| - expect(result['elements']['other'].first).to be_kind_of(WebDriver::Element) |
208 |
| - end |
209 |
| - end |
| 174 | + it "should return elements" do |
| 175 | + driver.navigate.to url_for("xhtmlTest.html") |
| 176 | + element = driver.execute_script("return document.getElementById('id1');") |
| 177 | + expect(element).to be_kind_of(WebDriver::Element) |
| 178 | + expect(element.text).to eq("Foo") |
| 179 | + end |
210 | 180 |
|
211 |
| - it "should return booleans" do |
| 181 | + not_compliant_on :browser => [:android] do |
| 182 | + it "should unwrap elements in deep objects" do |
212 | 183 | driver.navigate.to url_for("xhtmlTest.html")
|
213 |
| - expect(driver.execute_script("return true;")).to eq(true) |
| 184 | + result = driver.execute_script(<<-SCRIPT) |
| 185 | + var e1 = document.getElementById('id1'); |
| 186 | + var body = document.body; |
| 187 | +
|
| 188 | + return { |
| 189 | + elements: {'body' : body, other: [e1] } |
| 190 | + }; |
| 191 | + SCRIPT |
| 192 | + |
| 193 | + expect(result).to be_kind_of(Hash) |
| 194 | + expect(result['elements']['body']).to be_kind_of(WebDriver::Element) |
| 195 | + expect(result['elements']['other'].first).to be_kind_of(WebDriver::Element) |
214 | 196 | end
|
| 197 | + end |
215 | 198 |
|
216 |
| - it "should raise if the script is bad" do |
217 |
| - driver.navigate.to url_for("xhtmlTest.html") |
218 |
| - expect { driver.execute_script("return squiggle();") }.to raise_error |
219 |
| - end |
| 199 | + it "should return booleans" do |
| 200 | + driver.navigate.to url_for("xhtmlTest.html") |
| 201 | + expect(driver.execute_script("return true;")).to eq(true) |
| 202 | + end |
220 | 203 |
|
221 |
| - it "should return arrays" do |
222 |
| - driver.navigate.to url_for("xhtmlTest.html") |
223 |
| - expect(driver.execute_script('return ["zero", "one", "two"];')).to eq(%w[zero one two]) |
224 |
| - end |
| 204 | + it "should raise if the script is bad" do |
| 205 | + driver.navigate.to url_for("xhtmlTest.html") |
| 206 | + expect { driver.execute_script("return squiggle();") }.to raise_error |
| 207 | + end |
225 | 208 |
|
226 |
| - it "should be able to call functions on the page" do |
227 |
| - driver.navigate.to url_for("javascriptPage.html") |
228 |
| - driver.execute_script("displayMessage('I like cheese');") |
229 |
| - expect(driver.find_element(:id, "result").text.strip).to eq("I like cheese") |
230 |
| - end |
| 209 | + it "should return arrays" do |
| 210 | + driver.navigate.to url_for("xhtmlTest.html") |
| 211 | + expect(driver.execute_script('return ["zero", "one", "two"];')).to eq(%w[zero one two]) |
| 212 | + end |
231 | 213 |
|
232 |
| - it "should be able to pass string arguments" do |
233 |
| - driver.navigate.to url_for("javascriptPage.html") |
234 |
| - expect(driver.execute_script("return arguments[0] == 'fish' ? 'fish' : 'not fish';", "fish")).to eq("fish") |
235 |
| - end |
| 214 | + it "should be able to call functions on the page" do |
| 215 | + driver.navigate.to url_for("javascriptPage.html") |
| 216 | + driver.execute_script("displayMessage('I like cheese');") |
| 217 | + expect(driver.find_element(:id, "result").text.strip).to eq("I like cheese") |
| 218 | + end |
236 | 219 |
|
237 |
| - it "should be able to pass boolean arguments" do |
238 |
| - driver.navigate.to url_for("javascriptPage.html") |
239 |
| - expect(driver.execute_script("return arguments[0] == true;", true)).to eq(true) |
240 |
| - end |
| 220 | + it "should be able to pass string arguments" do |
| 221 | + driver.navigate.to url_for("javascriptPage.html") |
| 222 | + expect(driver.execute_script("return arguments[0] == 'fish' ? 'fish' : 'not fish';", "fish")).to eq("fish") |
| 223 | + end |
241 | 224 |
|
242 |
| - it "should be able to pass numeric arguments" do |
243 |
| - driver.navigate.to url_for("javascriptPage.html") |
244 |
| - expect(driver.execute_script("return arguments[0] == 1 ? 1 : 0;", 1)).to eq(1) |
245 |
| - end |
| 225 | + it "should be able to pass boolean arguments" do |
| 226 | + driver.navigate.to url_for("javascriptPage.html") |
| 227 | + expect(driver.execute_script("return arguments[0] == true;", true)).to eq(true) |
| 228 | + end |
246 | 229 |
|
247 |
| - it "should be able to pass null arguments" do |
248 |
| - driver.navigate.to url_for("javascriptPage.html") |
249 |
| - expect(driver.execute_script("return arguments[0];", nil)).to eq(nil) |
250 |
| - end |
| 230 | + it "should be able to pass numeric arguments" do |
| 231 | + driver.navigate.to url_for("javascriptPage.html") |
| 232 | + expect(driver.execute_script("return arguments[0] == 1 ? 1 : 0;", 1)).to eq(1) |
| 233 | + end |
251 | 234 |
|
252 |
| - it "should be able to pass array arguments" do |
253 |
| - driver.navigate.to url_for("javascriptPage.html") |
254 |
| - expect(driver.execute_script("return arguments[0];", [1, '2', 3])).to eq([1, '2', 3]) |
255 |
| - end |
| 235 | + it "should be able to pass null arguments" do |
| 236 | + driver.navigate.to url_for("javascriptPage.html") |
| 237 | + expect(driver.execute_script("return arguments[0];", nil)).to eq(nil) |
| 238 | + end |
256 | 239 |
|
257 |
| - it "should be able to pass element arguments" do |
258 |
| - driver.navigate.to url_for("javascriptPage.html") |
259 |
| - button = driver.find_element(:id, "plainButton") |
260 |
| - expect(driver.execute_script("arguments[0]['flibble'] = arguments[0].getAttribute('id'); return arguments[0]['flibble'];", button)).to eq("plainButton") |
261 |
| - end |
| 240 | + it "should be able to pass array arguments" do |
| 241 | + driver.navigate.to url_for("javascriptPage.html") |
| 242 | + expect(driver.execute_script("return arguments[0];", [1, '2', 3])).to eq([1, '2', 3]) |
| 243 | + end |
262 | 244 |
|
263 |
| - it "should be able to pass in multiple arguments" do |
264 |
| - driver.navigate.to url_for("javascriptPage.html") |
265 |
| - expect(driver.execute_script("return arguments[0] + arguments[1];", "one", "two")).to eq("onetwo") |
266 |
| - end |
| 245 | + it "should be able to pass element arguments" do |
| 246 | + driver.navigate.to url_for("javascriptPage.html") |
| 247 | + button = driver.find_element(:id, "plainButton") |
| 248 | + expect(driver.execute_script("arguments[0]['flibble'] = arguments[0].getAttribute('id'); return arguments[0]['flibble'];", button)).to eq("plainButton") |
| 249 | + end |
| 250 | + |
| 251 | + it "should be able to pass in multiple arguments" do |
| 252 | + driver.navigate.to url_for("javascriptPage.html") |
| 253 | + expect(driver.execute_script("return arguments[0] + arguments[1];", "one", "two")).to eq("onetwo") |
| 254 | + end |
267 | 255 | end
|
268 | 256 |
|
269 | 257 | not_compliant_on :browser => [:iphone, :android, :phantomjs] do
|
|
283 | 271 | expect(result).to eq(3)
|
284 | 272 | end
|
285 | 273 |
|
286 |
| - # TODO - File bug with Microsoft; this command returns status 21, should return status 28 |
| 274 | + # TODO - File Edge bug; this command returns status 21, should return status 28 |
287 | 275 | it "times out if the callback is not invoked" do
|
288 | 276 | expect {
|
289 | 277 | # Script is expected to be async and explicitly callback, so this should timeout.
|
|
0 commit comments