Skip to content

Commit f389150

Browse files
committed
rb - update support and specs for latest version of Edge driver
1 parent e45a461 commit f389150

File tree

7 files changed

+186
-217
lines changed

7 files changed

+186
-217
lines changed

rb/lib/selenium/webdriver/remote/bridge.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ def getAlert
158158
end
159159

160160
def acceptAlert
161-
command = capabilities.browser_name == 'MicrosoftEdge' ? :acceptAlertW3C : :acceptAlert
161+
command = :acceptAlert
162162
execute command
163163
end
164164

165165
def dismissAlert
166-
command = capabilities.browser_name == 'MicrosoftEdge' ? :dismissAlertW3C : :dismissAlert
166+
command = :dismissAlert
167167
execute command
168168
end
169169

@@ -173,7 +173,7 @@ def setAlertValue(keys)
173173
end
174174

175175
def getAlertText
176-
command = capabilities.browser_name == 'MicrosoftEdge' ? :getAlertTextW3C : :getAlertText
176+
command = :getAlertText
177177
execute command
178178
end
179179

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

Lines changed: 96 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,9 @@
2525
expect(driver.title).to eq("XHTML Test Page")
2626
end
2727

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)
3431
end
3532

3633
not_compliant_on :browser => :safari do
@@ -108,28 +105,22 @@
108105
expect(driver.find_element(:tag_name, 'div').attribute("class")).to eq("navigation")
109106
end
110107

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

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

119-
expect(child.attribute("id")).to eq("2")
120-
end
114+
expect(child.attribute("id")).to eq("2")
121115
end
122116

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

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

131-
expect(child.attribute("id")).to eq("2")
132-
end
123+
expect(child.attribute("id")).to eq("2")
133124
end
134125

135126
it "should raise on nonexistant element" do
@@ -161,109 +152,106 @@
161152
driver.find_elements(:css, 'p')
162153
end
163154

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)
172160
end
173161
end
174162

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
185168

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
192173

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
210180

211-
it "should return booleans" do
181+
not_compliant_on :browser => [:android] do
182+
it "should unwrap elements in deep objects" do
212183
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)
214196
end
197+
end
215198

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
220203

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
225208

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
231213

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
236219

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
241224

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
246229

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
251234

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
256239

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
262244

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
267255
end
268256

269257
not_compliant_on :browser => [:iphone, :android, :phantomjs] do
@@ -283,7 +271,7 @@
283271
expect(result).to eq(3)
284272
end
285273

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
287275
it "times out if the callback is not invoked" do
288276
expect {
289277
# Script is expected to be async and explicitly callback, so this should timeout.

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

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
driver.find_element(:id, "imageButton").click
2727
end
2828

29-
# TODO: File bug with Microsoft Edge documentation says this isn't supported, but it is
30-
# {POST} /session/{sessionId}/element/{id}/submit
3129
it "should submit" do
3230
driver.navigate.to url_for("formPage.html")
3331
driver.find_element(:id, "submitButton").submit
@@ -71,7 +69,7 @@
7169
expect(driver.find_element(:id, "withText").attribute("rows")).to eq("5")
7270
end
7371

74-
# TODO - File bug with Microsoft, this should return nil, but throws an error
72+
# TODO - File Edge bug, this should return nil, but throws an error
7573
# Selenium::WebDriver::Error::UnknownError: unknown error
7674
it "should return nil for non-existent attributes" do
7775
driver.navigate.to url_for("formPage.html")
@@ -135,19 +133,15 @@
135133
end
136134
end
137135

138-
# TODO - File bug with Microsoft, this command hangs
139-
# GET session/22A56752-2F60-45FB-B721-0CEB42CA77DF/element/4c3ee8d6-4ed4-492d-98c7-d8538366f7be/size
140-
not_compliant_on :browser => :edge do
141-
it "should get size" do
142-
driver.navigate.to url_for("xhtmlTest.html")
143-
size = driver.find_element(:class, "header").size
136+
it "should get size" do
137+
driver.navigate.to url_for("xhtmlTest.html")
138+
size = driver.find_element(:class, "header").size
144139

145-
expect(size.width).to be > 0
146-
expect(size.height).to be > 0
147-
end
140+
expect(size.width).to be > 0
141+
expect(size.height).to be > 0
148142
end
149143

150-
compliant_on :driver => [:ie, :chrome] do # Firefox w/native events: issue 1771
144+
compliant_on :driver => [:ie, :chrome, :edge] do # Firefox w/native events: issue 1771
151145
it "should drag and drop" do
152146
driver.navigate.to url_for("dragAndDropTest.html")
153147

@@ -207,16 +201,13 @@
207201
expect(body.hash).to eq(xbody.hash)
208202
end
209203

210-
# Edge does not yet support xpath location for {POST} /session/{sessionId}/elements
211-
not_compliant_on :browser => :edge do
212-
it "should return the same #hash for equal elements when found by Driver#find_elements" do
213-
driver.navigate.to url_for("simpleTest.html")
204+
it "should return the same #hash for equal elements when found by Driver#find_elements" do
205+
driver.navigate.to url_for("simpleTest.html")
214206

215-
body = driver.find_elements(:tag_name, 'body').fetch(0)
216-
xbody = driver.find_elements(:xpath, "//body").fetch(0)
207+
body = driver.find_elements(:tag_name, 'body').fetch(0)
208+
xbody = driver.find_elements(:xpath, "//body").fetch(0)
217209

218-
expect(body.hash).to eq(xbody.hash)
219-
end
210+
expect(body.hash).to eq(xbody.hash)
220211
end
221212

222213
end

0 commit comments

Comments
 (0)