Skip to content

Commit e4142a0

Browse files
committed
rb - update w3c commands and specs for element size & location
1 parent 6ccd656 commit e4142a0

File tree

2 files changed

+21
-31
lines changed

2 files changed

+21
-31
lines changed

rb/lib/selenium/webdriver/remote/w3c_bridge.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -567,19 +567,18 @@ def getElementText(element)
567567
end
568568

569569
def getElementLocation(element)
570-
data = execute :getElementLocation, :id => element
570+
data = execute :getElementRect, :id => element
571571

572572
Point.new data['x'], data['y']
573573
end
574574

575575
def getElementLocationOnceScrolledIntoView(element)
576-
data = execute :getElementLocationOnceScrolledIntoView, :id => element
577-
578-
Point.new data['x'], data['y']
576+
sendKeysToElement(element, [''])
577+
getElementLocation(element)
579578
end
580579

581580
def getElementSize(element)
582-
data = execute :getElementSize, :id => element
581+
data = execute :getElementRect, :id => element
583582

584583
Dimension.new data['width'], data['height']
585584
end

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

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -141,38 +141,30 @@
141141
expect(driver.find_element(:class, "header")).to be_displayed
142142
end
143143

144-
# Location not currently supported in Spec, but should be?
145-
not_compliant_on :browser => :marionette do
146-
it "should get location" do
147-
driver.navigate.to url_for("xhtmlTest.html")
148-
loc = driver.find_element(:class, "header").location
144+
it "should get location" do
145+
driver.navigate.to url_for("xhtmlTest.html")
146+
loc = driver.find_element(:class, "header").location
149147

150-
expect(loc.x).to be >= 1
151-
expect(loc.y).to be >= 1
152-
end
148+
expect(loc.x).to be >= 1
149+
expect(loc.y).to be >= 1
150+
end
153151

154-
not_compliant_on :browser => [:iphone] do
155-
it "should get location once scrolled into view" do
156-
driver.navigate.to url_for("javascriptPage.html")
157-
loc = driver.find_element(:id, 'keyUp').location_once_scrolled_into_view
152+
not_compliant_on :browser => :iphone do
153+
it "should get location once scrolled into view" do
154+
driver.navigate.to url_for("javascriptPage.html")
155+
loc = driver.find_element(:id, 'keyUp').location_once_scrolled_into_view
158156

159-
expect(loc.x).to be >= 1
160-
expect(loc.y).to be >= 0 # can be 0 if scrolled to the top
161-
end
157+
expect(loc.x).to be >= 1
158+
expect(loc.y).to be >= 0 # can be 0 if scrolled to the top
162159
end
163160
end
164161

165-
# Marionette BUG:
166-
# GET /session/f7082a32-e685-2843-ad2c-5bb6f376dac5/element/b6ff4468-ed6f-7c44-be4b-ca5a3ea8bf26/size
167-
# did not match a known command"
168-
not_compliant_on :browser => :marionette do
169-
it "should get size" do
170-
driver.navigate.to url_for("xhtmlTest.html")
171-
size = driver.find_element(:class, "header").size
162+
it "should get size" do
163+
driver.navigate.to url_for("xhtmlTest.html")
164+
size = driver.find_element(:class, "header").size
172165

173-
expect(size.width).to be > 0
174-
expect(size.height).to be > 0
175-
end
166+
expect(size.width).to be > 0
167+
expect(size.height).to be > 0
176168
end
177169

178170
compliant_on :driver => [:ie, :chrome, :edge] do # Firefox w/native events: issue 1771
@@ -243,5 +235,4 @@
243235

244236
expect(body.hash).to eq(xbody.hash)
245237
end
246-
247238
end

0 commit comments

Comments
 (0)