Skip to content

Commit d4a50f1

Browse files
committed
rb: update specs for Microsoft Edge
1 parent 057e2bc commit d4a50f1

File tree

10 files changed

+353
-265
lines changed

10 files changed

+353
-265
lines changed

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

+121-97
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,18 @@
2525
driver.title.should == "XHTML Test Page"
2626
end
2727

28-
it "should get the page source" do
29-
driver.navigate.to url_for("xhtmlTest.html")
30-
driver.page_source.should match(%r[<title>XHTML Test Page</title>]i)
28+
# Edge does not yet support session/:sessionId/source http://dev.modern.ie/platform/status/webdriver/details/
29+
not_compliant_on :browser => :edge do
30+
it "should get the page source" do
31+
driver.navigate.to url_for("xhtmlTest.html")
32+
driver.page_source.should match(%r[<title>XHTML Test Page</title>]i)
33+
end
3134
end
3235

33-
3436
not_compliant_on :browser => :safari do
3537
it "should refresh the page" do
3638
driver.navigate.to url_for("javascriptPage.html")
37-
driver.find_element(:link_text, 'Update a div').click
39+
driver.find_element(:id, 'updatediv').click
3840
driver.find_element(:id, 'dynamo').text.should == "Fish and chips!"
3941
driver.navigate.refresh
4042
driver.find_element(:id, 'dynamo').text.should == "What's for dinner?"
@@ -91,9 +93,12 @@
9193
driver.find_element(:link, "Foo").text.should == "Foo"
9294
end
9395

94-
it "should find by xpath" do
95-
driver.navigate.to url_for("xhtmlTest.html")
96-
driver.find_element(:xpath, "//h1").text.should == "XHTML Might Be The Future"
96+
# Edge does not yet support xpath
97+
not_compliant_on :browser => :edge do
98+
it "should find by xpath" do
99+
driver.navigate.to url_for("xhtmlTest.html")
100+
driver.find_element(:xpath, "//h1").text.should == "XHTML Might Be The Future"
101+
end
97102
end
98103

99104
it "should find by css selector" do
@@ -106,22 +111,30 @@
106111
driver.find_element(:tag_name, 'div').attribute("class").should == "navigation"
107112
end
108113

109-
it "should find child element" do
110-
driver.navigate.to url_for("nestedElements.html")
114+
# Edge does not yet support session/:sessionId/element/:id/element
115+
# http://dev.modern.ie/platform/status/webdriver/details/
116+
not_compliant_on :browser => :edge do
117+
it "should find child element" do
118+
driver.navigate.to url_for("nestedElements.html")
111119

112-
element = driver.find_element(:name, "form2")
113-
child = element.find_element(:name, "selectomatic")
120+
element = driver.find_element(:name, "form2")
121+
child = element.find_element(:name, "selectomatic")
114122

115-
child.attribute("id").should == "2"
123+
child.attribute("id").should == "2"
124+
end
116125
end
117126

118-
it "should find child element by tag name" do
119-
driver.navigate.to url_for("nestedElements.html")
127+
# Edge does not yet support session/:sessionId/element/:id/element
128+
# http://dev.modern.ie/platform/status/webdriver/details/
129+
not_compliant_on :browser => :edge do
130+
it "should find child element by tag name" do
131+
driver.navigate.to url_for("nestedElements.html")
120132

121-
element = driver.find_element(:name, "form2")
122-
child = element.find_element(:tag_name, "select")
133+
element = driver.find_element(:name, "form2")
134+
child = element.find_element(:tag_name, "select")
123135

124-
child.attribute("id").should == "2"
136+
child.attribute("id").should == "2"
137+
end
125138
end
126139

127140
it "should raise on nonexistant element" do
@@ -134,11 +147,14 @@
134147
driver.find_element(:class => "header").text.should == "XHTML Might Be The Future"
135148
end
136149

137-
it "should find elements with the shortcut syntax" do
138-
driver.navigate.to url_for("xhtmlTest.html")
150+
# Edge does not yet support xpath
151+
not_compliant_on :browser => :edge do
152+
it "should find elements with the shortcut syntax" do
153+
driver.navigate.to url_for("xhtmlTest.html")
139154

140-
driver[:id1].should be_kind_of(WebDriver::Element)
141-
driver[:xpath => "//h1"].should be_kind_of(WebDriver::Element)
155+
driver[:id1].should be_kind_of(WebDriver::Element)
156+
driver[:xpath => "//h1"].should be_kind_of(WebDriver::Element)
157+
end
142158
end
143159
end
144160

@@ -153,109 +169,117 @@
153169
driver.find_elements(:css, 'p')
154170
end
155171

156-
it "should find children by field name" do
157-
driver.navigate.to url_for("nestedElements.html")
158-
element = driver.find_element(:name, "form2")
159-
children = element.find_elements(:name, "selectomatic")
160-
expect(children.size).to eq(2)
172+
# Edge does not yet support session/:sessionId/element/:id/element
173+
# http://dev.modern.ie/platform/status/webdriver/details/
174+
not_compliant_on :browser => :edge do
175+
it "should find children by field name" do
176+
driver.navigate.to url_for("nestedElements.html")
177+
element = driver.find_element(:name, "form2")
178+
children = element.find_elements(:name, "selectomatic")
179+
expect(children.size).to eq(2)
180+
end
161181
end
162182
end
163183

164-
describe "execute script" do
165-
it "should return strings" do
166-
driver.navigate.to url_for("xhtmlTest.html")
167-
driver.execute_script("return document.title;").should == "XHTML Test Page"
168-
end
169-
170-
it "should return numbers" do
171-
driver.navigate.to url_for("xhtmlTest.html")
172-
driver.execute_script("return document.title.length;").should == "XHTML Test Page".length
173-
end
184+
# Microsoft Edge does not return javascriptEnabled when passed in as desired capabilities
185+
not_compliant_on :browser => :edge do
186+
describe "execute script" do
187+
it "should return strings" do
188+
driver.navigate.to url_for("xhtmlTest.html")
189+
driver.execute_script("return document.title;").should == "XHTML Test Page"
190+
end
174191

175-
it "should return elements" do
176-
driver.navigate.to url_for("xhtmlTest.html")
177-
element = driver.execute_script("return document.getElementById('id1');")
178-
element.should be_kind_of(WebDriver::Element)
179-
element.text.should == "Foo"
180-
end
192+
it "should return numbers" do
193+
driver.navigate.to url_for("xhtmlTest.html")
194+
driver.execute_script("return document.title.length;").should == "XHTML Test Page".length
195+
end
181196

182-
not_compliant_on :browser => [:android] do
183-
it "should unwrap elements in deep objects" do
197+
it "should return elements" do
184198
driver.navigate.to url_for("xhtmlTest.html")
185-
result = driver.execute_script(<<-SCRIPT)
199+
element = driver.execute_script("return document.getElementById('id1');")
200+
element.should be_kind_of(WebDriver::Element)
201+
element.text.should == "Foo"
202+
end
203+
204+
not_compliant_on :browser => [:android] do
205+
it "should unwrap elements in deep objects" do
206+
driver.navigate.to url_for("xhtmlTest.html")
207+
result = driver.execute_script(<<-SCRIPT)
186208
var e1 = document.getElementById('id1');
187209
var body = document.body;
188210
189211
return {
190212
elements: {'body' : body, other: [e1] }
191213
};
192-
SCRIPT
214+
SCRIPT
193215

194-
result.should be_kind_of(Hash)
195-
result['elements']['body'].should be_kind_of(WebDriver::Element)
196-
result['elements']['other'].first.should be_kind_of(WebDriver::Element)
216+
result.should be_kind_of(Hash)
217+
result['elements']['body'].should be_kind_of(WebDriver::Element)
218+
result['elements']['other'].first.should be_kind_of(WebDriver::Element)
219+
end
197220
end
198-
end
199221

200-
it "should return booleans" do
201-
driver.navigate.to url_for("xhtmlTest.html")
202-
driver.execute_script("return true;").should == true
203-
end
222+
it "should return booleans" do
223+
driver.navigate.to url_for("xhtmlTest.html")
224+
driver.execute_script("return true;").should == true
225+
end
204226

205-
it "should raise if the script is bad" do
206-
driver.navigate.to url_for("xhtmlTest.html")
207-
lambda { driver.execute_script("return squiggle();") }.should raise_error
208-
end
227+
it "should raise if the script is bad" do
228+
driver.navigate.to url_for("xhtmlTest.html")
229+
lambda { driver.execute_script("return squiggle();") }.should raise_error
230+
end
209231

210-
it "should return arrays" do
211-
driver.navigate.to url_for("xhtmlTest.html")
212-
driver.execute_script('return ["zero", "one", "two"];').should == %w[zero one two]
213-
end
232+
it "should return arrays" do
233+
driver.navigate.to url_for("xhtmlTest.html")
234+
driver.execute_script('return ["zero", "one", "two"];').should == %w[zero one two]
235+
end
214236

215-
it "should be able to call functions on the page" do
216-
driver.navigate.to url_for("javascriptPage.html")
217-
driver.execute_script("displayMessage('I like cheese');")
218-
driver.find_element(:id, "result").text.strip.should == "I like cheese"
219-
end
237+
it "should be able to call functions on the page" do
238+
driver.navigate.to url_for("javascriptPage.html")
239+
driver.execute_script("displayMessage('I like cheese');")
240+
driver.find_element(:id, "result").text.strip.should == "I like cheese"
241+
end
220242

221-
it "should be able to pass string arguments" do
222-
driver.navigate.to url_for("javascriptPage.html")
223-
driver.execute_script("return arguments[0] == 'fish' ? 'fish' : 'not fish';", "fish").should == "fish"
224-
end
243+
it "should be able to pass string arguments" do
244+
driver.navigate.to url_for("javascriptPage.html")
245+
driver.execute_script("return arguments[0] == 'fish' ? 'fish' : 'not fish';", "fish").should == "fish"
246+
end
225247

226-
it "should be able to pass boolean arguments" do
227-
driver.navigate.to url_for("javascriptPage.html")
228-
driver.execute_script("return arguments[0] == true;", true).should == true
229-
end
248+
it "should be able to pass boolean arguments" do
249+
driver.navigate.to url_for("javascriptPage.html")
250+
driver.execute_script("return arguments[0] == true;", true).should == true
251+
end
230252

231-
it "should be able to pass numeric arguments" do
232-
driver.navigate.to url_for("javascriptPage.html")
233-
driver.execute_script("return arguments[0] == 1 ? 1 : 0;", 1).should == 1
234-
end
253+
it "should be able to pass numeric arguments" do
254+
driver.navigate.to url_for("javascriptPage.html")
255+
driver.execute_script("return arguments[0] == 1 ? 1 : 0;", 1).should == 1
256+
end
235257

236-
it "should be able to pass null arguments" do
237-
driver.navigate.to url_for("javascriptPage.html")
238-
driver.execute_script("return arguments[0];", nil).should == nil
239-
end
258+
it "should be able to pass null arguments" do
259+
driver.navigate.to url_for("javascriptPage.html")
260+
driver.execute_script("return arguments[0];", nil).should == nil
261+
end
240262

241-
it "should be able to pass array arguments" do
242-
driver.navigate.to url_for("javascriptPage.html")
243-
driver.execute_script("return arguments[0];", [1, '2', 3]).should == [1, '2', 3]
244-
end
263+
it "should be able to pass array arguments" do
264+
driver.navigate.to url_for("javascriptPage.html")
265+
driver.execute_script("return arguments[0];", [1, '2', 3]).should == [1, '2', 3]
266+
end
245267

246-
it "should be able to pass element arguments" do
247-
driver.navigate.to url_for("javascriptPage.html")
248-
button = driver.find_element(:id, "plainButton")
249-
driver.execute_script("arguments[0]['flibble'] = arguments[0].getAttribute('id'); return arguments[0]['flibble'];", button).should == "plainButton"
250-
end
268+
it "should be able to pass element arguments" do
269+
driver.navigate.to url_for("javascriptPage.html")
270+
button = driver.find_element(:id, "plainButton")
271+
driver.execute_script("arguments[0]['flibble'] = arguments[0].getAttribute('id'); return arguments[0]['flibble'];", button).should == "plainButton"
272+
end
251273

252-
it "should be able to pass in multiple arguments" do
253-
driver.navigate.to url_for("javascriptPage.html")
254-
driver.execute_script("return arguments[0] + arguments[1];", "one", "two").should == "onetwo"
274+
it "should be able to pass in multiple arguments" do
275+
driver.navigate.to url_for("javascriptPage.html")
276+
driver.execute_script("return arguments[0] + arguments[1];", "one", "two").should == "onetwo"
277+
end
255278
end
256279
end
257280

258-
not_compliant_on :browser => [:iphone, :android, :phantomjs] do
281+
# Microsoft Edge does not return javascriptEnabled when passed in as desired capabilities
282+
not_compliant_on :browser => [:iphone, :android, :phantomjs, :edge] do
259283
describe "execute async script" do
260284
before {
261285
driver.manage.timeouts.script_timeout = 0

0 commit comments

Comments
 (0)