Skip to content

Commit 2bb9c0b

Browse files
ShockwaveNNp0deje
authored andcommitted
ActionBuilder#move_by should send only Integer coordinates
I'm not sure why, but if I send coordinates like this to mouseMoveTo: `@driver.action.move_to(element, 330.1, 13).click.perform` it click in one part of page, wrong part But if i send `@driver.action.move_to(element, 330, 13).click.perform` it wors fine. Maybe it somewhat depends on http call, that performs - they looks like ``` "{"element":"0.14091974799732143-9","xoffset":330.1,"yoffset":13}" "{"element":"0.23202931091340706-9","xoffset":330,"yoffset":13}" ``` and fraction part somwehow messed up requests. Same thing apply to `ActionBuilder#move_to` Also add specs for `move_to` `move_by` with floating point Signed-off-by: Alex Rodionov <[email protected]>
1 parent 40c2033 commit 2bb9c0b

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

rb/lib/selenium/webdriver/common/action_builder.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def double_click(element = nil)
253253

254254
def move_to(element, right_by = nil, down_by = nil)
255255
if right_by && down_by
256-
@actions << [:mouse, :move_to, [element, right_by, down_by]]
256+
@actions << [:mouse, :move_to, [element, Integer(right_by), Integer(down_by)]]
257257
else
258258
@actions << [:mouse, :move_to, [element]]
259259
end
@@ -281,7 +281,7 @@ def move_to(element, right_by = nil, down_by = nil)
281281
#
282282

283283
def move_by(right_by, down_by)
284-
@actions << [:mouse, :move_by, [right_by, down_by]]
284+
@actions << [:mouse, :move_by, [Integer(right_by), Integer(down_by)]]
285285
self
286286
end
287287

rb/spec/unit/selenium/webdriver/action_builder_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,19 @@
7575
context_click(element).perform
7676
end
7777

78+
it 'should move_to ignore floating point part of coordinate' do
79+
expect(mouse).to receive(:move_to).with(element, -300, 400)
80+
81+
builder.move_to(element, -300.1, 400.1).perform
82+
end
83+
84+
it 'should move_by ignore floating point part of coordinate' do
85+
expect(mouse).to receive(:move_by).with(-300, 400)
86+
87+
builder.move_by(-300.1, 400.1).perform
88+
end
89+
90+
7891
it "should drag and drop" do
7992
source = element
8093
target = Selenium::WebDriver::Element.new(bridge, 'element2')

0 commit comments

Comments
 (0)