Skip to content

Commit 3df463f

Browse files
committed
rb - removed unnecessary guards on specs
1 parent 2917565 commit 3df463f

16 files changed

+134
-142
lines changed

rb/spec/integration/selenium/webdriver/app_cache_spec.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
require_relative 'spec_helper'
2121

22-
2322
module Selenium::WebDriver::DriverExtensions
24-
describe "HasApplicationCache" do
2523

26-
compliant_on :browser => nil do
24+
compliant_on :browser => nil do
25+
describe "HasApplicationCache" do
26+
2727
it "gets the app cache status" do
2828
expect(driver.application_cache.status).to eq(:uncached)
2929

@@ -61,6 +61,5 @@ module Selenium::WebDriver::DriverExtensions
6161
end
6262
end
6363
end
64-
6564
end
6665
end

rb/spec/integration/selenium/webdriver/driver_spec.rb

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
require_relative 'spec_helper'
2121

2222
describe "Driver" do
23+
2324
it "should get the page title" do
2425
driver.navigate.to url_for("xhtmlTest.html")
2526
expect(driver.title).to eq("XHTML Test Page")
@@ -30,44 +31,47 @@
3031
expect(driver.page_source).to match(%r[<title>XHTML Test Page</title>]i)
3132
end
3233

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?")
4141
end
4242

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
5457
end
55-
end
5658

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")
5961

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
6466

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
6770
end
6871
end
6972

7073
describe "one element" do
74+
7175
it "should find by id" do
7276
driver.navigate.to url_for("xhtmlTest.html")
7377
element = driver.find_element(:id, "id1")
@@ -109,7 +113,7 @@
109113
driver.navigate.to url_for("nestedElements.html")
110114

111115
element = driver.find_element(:name, "form2")
112-
child = element.find_element(:name, "selectomatic")
116+
child = element.find_element(:name, "selectomatic")
113117

114118
expect(child.attribute("id")).to eq("2")
115119
end
@@ -118,7 +122,7 @@
118122
driver.navigate.to url_for("nestedElements.html")
119123

120124
element = driver.find_element(:name, "form2")
121-
child = element.find_element(:tag_name, "select")
125+
child = element.find_element(:tag_name, "select")
122126

123127
expect(child.attribute("id")).to eq("2")
124128
end
@@ -142,6 +146,7 @@
142146
end
143147

144148
describe "many elements" do
149+
145150
it "should find by class name" do
146151
driver.navigate.to url_for("xhtmlTest.html")
147152
expect(driver.find_elements(:class, "nameC").size).to eq(2)
@@ -161,6 +166,7 @@
161166
end
162167

163168
describe "execute script" do
169+
164170
it "should return strings" do
165171
driver.navigate.to url_for("xhtmlTest.html")
166172
expect(driver.execute_script("return document.title;")).to eq("XHTML Test Page")
@@ -212,7 +218,7 @@
212218
end
213219

214220
# Marionette BUG - Not finding local javascript for execution
215-
not_compliant_on({:driver => :marionette}, {:browser => :marionette}) do
221+
not_compliant_on :browser => :marionette do
216222
it "should be able to call functions on the page" do
217223
driver.navigate.to url_for("javascriptPage.html")
218224
driver.execute_script("displayMessage('I like cheese');")
@@ -257,12 +263,13 @@
257263
end
258264
end
259265

260-
not_compliant_on :browser => [:iphone, :android, :phantomjs] do
266+
not_compliant_on :browser => [:iphone, :android] do
261267
describe "execute async script" do
262-
before {
268+
269+
before do
263270
driver.manage.timeouts.script_timeout = 0
264271
driver.navigate.to url_for("ajaxy_page.html")
265-
}
272+
end
266273

267274
it "should be able to return arrays of primitives from async scripts" do
268275
result = driver.execute_async_script "arguments[arguments.length - 1]([null, 123, 'abc', true, false]);"
@@ -275,7 +282,8 @@
275282
end
276283

277284
# 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
279287
it "times out if the callback is not invoked" do
280288
expect {
281289
# Script is expected to be async and explicitly callback, so this should timeout.
@@ -285,5 +293,4 @@
285293
end
286294
end
287295
end
288-
289296
end

rb/spec/integration/selenium/webdriver/element_spec.rb

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,18 @@
3939
not_compliant_on :browser => :marionette do
4040
it "should submit" do
4141
driver.navigate.to url_for("formPage.html")
42-
wait(5).until {driver.find_elements(:id, "submitButton").size > 0}
42+
wait_for_element(:id => "submitButton")
4343
driver.find_element(:id, "submitButton").submit
4444
end
4545
end
4646

4747
it "should send string keys" do
4848
driver.navigate.to url_for("formPage.html")
49+
wait_for_element(:id => "working")
4950
driver.find_element(:id, "working").send_keys("foo", "bar")
5051
end
5152

52-
not_compliant_on :browser => [:android, :iphone, :safari] do
53+
not_compliant_on :browser => [:android, :iphone] do
5354
it "should send key presses" do
5455
driver.navigate.to url_for("javascriptPage.html")
5556
key_reporter = driver.find_element(:id, 'keyReporter')
@@ -59,12 +60,8 @@
5960
end
6061
end
6162

62-
# FIXME - Find alternate implementation for File Uploads
63-
# TODO - Figure out if/how this works on Firefox/Chrome without Remote server
6463
# PhantomJS on windows issue: https://github.com/ariya/phantomjs/issues/10993
65-
not_compliant_on({:browser => [:android, :iphone, :safari, :edge, :marionette]},
66-
{:browser => :phantomjs, :platform => [:windows, :linux]},
67-
{:driver => :marionette}) do
64+
not_compliant_on :browser => [:android, :iphone, :safari, :edge, :marionette, :phantomjs] do
6865
it "should handle file uploads" do
6966
driver.navigate.to url_for("formPage.html")
7067

@@ -93,15 +90,6 @@
9390
end
9491
end
9592

96-
# Per W3C spec this should return Invalid Argument not Unknown Error, but there is no comparable error code
97-
compliant_on :browser => :edge do
98-
it "should return nil for non-existent attributes" do
99-
driver.navigate.to url_for("formPage.html")
100-
element = driver.find_element(:id, "withText")
101-
expect {element.attribute("nonexistent")}.to raise_error(Selenium::WebDriver::Error::UnknownError)
102-
end
103-
end
104-
10593
it "should clear" do
10694
driver.navigate.to url_for("formPage.html")
10795
driver.find_element(:id, "withText").clear
@@ -167,7 +155,7 @@
167155
expect(size.height).to be > 0
168156
end
169157

170-
compliant_on :driver => [:ie, :chrome, :edge] do # Firefox w/native events: issue 1771
158+
not_compliant_on :browser => [:safari, :marionette] do
171159
it "should drag and drop" do
172160
driver.navigate.to url_for("dragAndDropTest.html")
173161

@@ -182,7 +170,7 @@
182170
end
183171
end
184172

185-
not_compliant_on :browser => [:android] do # android returns 'green'
173+
not_compliant_on :browser => :android do # android returns 'green'
186174
it "should get css property" do
187175
driver.navigate.to url_for("javascriptPage.html")
188176
element = driver.find_element(:id, "green-parent")
@@ -205,17 +193,15 @@
205193
expect(body).to eql(xbody)
206194
end
207195

208-
not_compliant_on :browser => :phantomjs do
209-
it "should know when two elements are not equal" do
210-
driver.navigate.to url_for("simpleTest.html")
196+
it "should know when two elements are not equal" do
197+
driver.navigate.to url_for("simpleTest.html")
211198

212-
elements = driver.find_elements(:tag_name, 'p')
213-
p1 = elements.fetch(0)
214-
p2 = elements.fetch(1)
199+
elements = driver.find_elements(:tag_name, 'p')
200+
p1 = elements.fetch(0)
201+
p2 = elements.fetch(1)
215202

216-
expect(p1).not_to eq(p2)
217-
expect(p1).not_to eql(p2)
218-
end
203+
expect(p1).not_to eq(p2)
204+
expect(p1).not_to eql(p2)
219205
end
220206

221207
it "should return the same #hash for equal elements when found by Driver#find_element" do

rb/spec/integration/selenium/webdriver/error_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
}.to raise_error(WebDriver::Error::NoSuchElementError)
3030
end
3131

32-
compliant_on({:driver => :firefox}, {:driver => :remote, :browser => :firefox}) do
32+
compliant_on :browser => :firefox do
3333
it "should show stack trace information" do
3434
driver.navigate.to url_for("xhtmlTest.html")
3535

rb/spec/integration/selenium/webdriver/firefox/marionette_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ module Selenium
2323
module WebDriver
2424

2525
describe Firefox do
26-
before(:each) do
26+
before do
2727
@opt = GlobalTestEnv.remote_server? ? {:url => GlobalTestEnv.remote_server.webdriver_url} : {}
2828
end
2929

3030
context "when designated firefox binary includes Marionette" do
31-
before(:each) do
31+
before do
3232
unless ENV['MARIONETTE_PATH']
3333
pending "Set ENV['MARIONETTE_PATH'] to test Marionette enabled Firefox installations"
3434
end

rb/spec/integration/selenium/webdriver/keyboard_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ module Selenium
2323
module WebDriver
2424

2525
# Marionette BUG - Interactions Not Supported
26-
not_compliant_on({:browser => [:chrome, :android, :iphone, :safari, :marionette]},
27-
{:driver => :marionette}) do
26+
not_compliant_on :browser => [:android, :iphone, :safari, :marionette] do
2827
describe Keyboard do
28+
2929
it "sends keys to the active element" do
3030
driver.navigate.to url_for("bodyTypingTest.html")
3131

rb/spec/integration/selenium/webdriver/mouse_spec.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@
2222
module Selenium
2323
module WebDriver
2424

25-
describe Mouse do
25+
# Marionette BUG - Interactions Not Supported
26+
not_compliant_on :browser => [:android, :iphone, :safari, :marionette] do
27+
describe Mouse do
2628

27-
# Marionette BUG - Interactions Not Supported
28-
not_compliant_on({:browser => [:android, :iphone, :safari, :marionette]},
29-
{:driver => :marionette}) do
3029
it "clicks an element" do
3130
driver.navigate.to url_for("formPage.html")
3231
driver.mouse.click driver.find_element(:id, "imageButton")
@@ -76,7 +75,6 @@ module WebDriver
7675
end
7776
end
7877
end
79-
8078
end
8179
end
8280
end

rb/spec/integration/selenium/webdriver/navigation_spec.rb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
require_relative 'spec_helper'
2121

2222
describe "Navigation" do
23-
let(:wait) { Selenium::WebDriver::Wait.new :timeout => 10 }
2423

2524
not_compliant_on :browser => :safari do
2625
it "should navigate back and forward" do
@@ -47,19 +46,18 @@
4746
expect(driver.current_url).to include(result_url)
4847
expect(driver.title).to eq(result_title)
4948
end
49+
end
5050

51-
it "should refresh the page" do
52-
changed_title = "Changed"
51+
it "should refresh the page" do
52+
changed_title = "Changed"
5353

54-
driver.navigate.to url_for("javascriptPage.html")
55-
driver.find_element(:link_text, "Change the page title!").click
56-
expect(driver.title).to eq(changed_title)
54+
driver.navigate.to url_for("javascriptPage.html")
55+
driver.find_element(:link_text, "Change the page title!").click
56+
expect(driver.title).to eq(changed_title)
5757

58-
driver.navigate.refresh
59-
wait.until { driver.title != changed_title }
58+
driver.navigate.refresh
59+
wait.until { driver.title != changed_title }
6060

61-
expect(driver.title).to eq("Testing Javascript")
62-
end
61+
expect(driver.title).to eq("Testing Javascript")
6362
end
6463
end
65-

0 commit comments

Comments
 (0)