|
20 | 20 | require_relative 'spec_helper'
|
21 | 21 |
|
22 | 22 | describe "Driver" do
|
| 23 | + |
23 | 24 | it "should get the page title" do
|
24 | 25 | driver.navigate.to url_for("xhtmlTest.html")
|
25 | 26 | expect(driver.title).to eq("XHTML Test Page")
|
|
30 | 31 | expect(driver.page_source).to match(%r[<title>XHTML Test Page</title>]i)
|
31 | 32 | end
|
32 | 33 |
|
33 |
| - not_compliant_on :browser => :safari do |
34 |
| - it "should refresh the page" do |
35 |
| - driver.navigate.to url_for("javascriptPage.html") |
36 |
| - driver.find_element(:id, 'updatediv').click |
37 |
| - expect(driver.find_element(:id, 'dynamo').text).to eq("Fish and chips!") |
38 |
| - driver.navigate.refresh |
39 |
| - expect(driver.find_element(:id, 'dynamo').text).to eq("What's for dinner?") |
40 |
| - end |
| 34 | + it "should refresh the page" do |
| 35 | + driver.navigate.to url_for("javascriptPage.html") |
| 36 | + sleep 1 # javascript takes too long to load |
| 37 | + driver.find_element(:id, 'updatediv').click |
| 38 | + expect(driver.find_element(:id, 'dynamo').text).to eq("Fish and chips!") |
| 39 | + driver.navigate.refresh |
| 40 | + expect(driver.find_element(:id, 'dynamo').text).to eq("What's for dinner?") |
41 | 41 | end
|
42 | 42 |
|
43 |
| - not_compliant_on :browser => [ :iphone, :safari] do |
44 |
| - it "should save a screenshot" do |
45 |
| - driver.navigate.to url_for("xhtmlTest.html") |
46 |
| - path = "screenshot_tmp.png" |
47 |
| - |
48 |
| - begin |
49 |
| - driver.save_screenshot path |
50 |
| - expect(File.exist?(path)).to be true # sic |
51 |
| - expect(File.size(path)).to be > 0 |
52 |
| - ensure |
53 |
| - File.delete(path) if File.exist?(path) |
| 43 | + not_compliant_on :browser => :iphone do |
| 44 | + context "screenshots" do |
| 45 | + |
| 46 | + it "should save" do |
| 47 | + driver.navigate.to url_for("xhtmlTest.html") |
| 48 | + path = "screenshot_tmp.png" |
| 49 | + |
| 50 | + begin |
| 51 | + driver.save_screenshot path |
| 52 | + expect(File.exist?(path)).to be true # sic |
| 53 | + expect(File.size(path)).to be > 0 |
| 54 | + ensure |
| 55 | + File.delete(path) if File.exist?(path) |
| 56 | + end |
54 | 57 | end
|
55 |
| - end |
56 | 58 |
|
57 |
| - it "should return a screenshot in the specified format" do |
58 |
| - driver.navigate.to url_for("xhtmlTest.html") |
| 59 | + it "should return in the specified format" do |
| 60 | + driver.navigate.to url_for("xhtmlTest.html") |
59 | 61 |
|
60 |
| - ss = driver.screenshot_as(:png) |
61 |
| - expect(ss).to be_kind_of(String) |
62 |
| - expect(ss.size).to be > 0 |
63 |
| - end |
| 62 | + ss = driver.screenshot_as(:png) |
| 63 | + expect(ss).to be_kind_of(String) |
| 64 | + expect(ss.size).to be > 0 |
| 65 | + end |
64 | 66 |
|
65 |
| - it "raises an error when given an unknown format" do |
66 |
| - expect { driver.screenshot_as(:jpeg) }.to raise_error(WebDriver::Error::UnsupportedOperationError) |
| 67 | + it "raises an error when given an unknown format" do |
| 68 | + expect { driver.screenshot_as(:jpeg) }.to raise_error(WebDriver::Error::UnsupportedOperationError) |
| 69 | + end |
67 | 70 | end
|
68 | 71 | end
|
69 | 72 |
|
70 | 73 | describe "one element" do
|
| 74 | + |
71 | 75 | it "should find by id" do
|
72 | 76 | driver.navigate.to url_for("xhtmlTest.html")
|
73 | 77 | element = driver.find_element(:id, "id1")
|
|
109 | 113 | driver.navigate.to url_for("nestedElements.html")
|
110 | 114 |
|
111 | 115 | element = driver.find_element(:name, "form2")
|
112 |
| - child = element.find_element(:name, "selectomatic") |
| 116 | + child = element.find_element(:name, "selectomatic") |
113 | 117 |
|
114 | 118 | expect(child.attribute("id")).to eq("2")
|
115 | 119 | end
|
|
118 | 122 | driver.navigate.to url_for("nestedElements.html")
|
119 | 123 |
|
120 | 124 | element = driver.find_element(:name, "form2")
|
121 |
| - child = element.find_element(:tag_name, "select") |
| 125 | + child = element.find_element(:tag_name, "select") |
122 | 126 |
|
123 | 127 | expect(child.attribute("id")).to eq("2")
|
124 | 128 | end
|
|
142 | 146 | end
|
143 | 147 |
|
144 | 148 | describe "many elements" do
|
| 149 | + |
145 | 150 | it "should find by class name" do
|
146 | 151 | driver.navigate.to url_for("xhtmlTest.html")
|
147 | 152 | expect(driver.find_elements(:class, "nameC").size).to eq(2)
|
|
161 | 166 | end
|
162 | 167 |
|
163 | 168 | describe "execute script" do
|
| 169 | + |
164 | 170 | it "should return strings" do
|
165 | 171 | driver.navigate.to url_for("xhtmlTest.html")
|
166 | 172 | expect(driver.execute_script("return document.title;")).to eq("XHTML Test Page")
|
|
212 | 218 | end
|
213 | 219 |
|
214 | 220 | # Marionette BUG - Not finding local javascript for execution
|
215 |
| - not_compliant_on({:driver => :marionette}, {:browser => :marionette}) do |
| 221 | + not_compliant_on :browser => :marionette do |
216 | 222 | it "should be able to call functions on the page" do
|
217 | 223 | driver.navigate.to url_for("javascriptPage.html")
|
218 | 224 | driver.execute_script("displayMessage('I like cheese');")
|
|
257 | 263 | end
|
258 | 264 | end
|
259 | 265 |
|
260 |
| - not_compliant_on :browser => [:iphone, :android, :phantomjs] do |
| 266 | + not_compliant_on :browser => [:iphone, :android] do |
261 | 267 | describe "execute async script" do
|
262 |
| - before { |
| 268 | + |
| 269 | + before do |
263 | 270 | driver.manage.timeouts.script_timeout = 0
|
264 | 271 | driver.navigate.to url_for("ajaxy_page.html")
|
265 |
| - } |
| 272 | + end |
266 | 273 |
|
267 | 274 | it "should be able to return arrays of primitives from async scripts" do
|
268 | 275 | result = driver.execute_async_script "arguments[arguments.length - 1]([null, 123, 'abc', true, false]);"
|
|
275 | 282 | end
|
276 | 283 |
|
277 | 284 | # Edge BUG - https://connect.microsoft.com/IE/feedback/details/1849991/
|
278 |
| - not_compliant_on({:browser => :edge}, {:driver => :remote, :browser => :marionette}) do |
| 285 | + not_compliant_on({:browser => [:edge, :marionette]}, |
| 286 | + {:driver => :remote, :browser => :phantomjs}) do |
279 | 287 | it "times out if the callback is not invoked" do
|
280 | 288 | expect {
|
281 | 289 | # Script is expected to be async and explicitly callback, so this should timeout.
|
|
285 | 293 | end
|
286 | 294 | end
|
287 | 295 | end
|
288 |
| - |
289 | 296 | end
|
0 commit comments