Skip to content

Commit 583a088

Browse files
author
Bobby Jap
committed
Fixed methods that use dimensions relative to a given WebElement
1 parent 8666224 commit 583a088

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main/java/io/appium/java_client/AppiumDriver.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,10 @@ public void pinch(WebElement el) {
401401
Dimension dimensions = el.getSize();
402402
Point upperLeft = el.getLocation();
403403
Point center = new Point(upperLeft.getX() + dimensions.getWidth() / 2, upperLeft.getY() + dimensions.getHeight() / 2);
404+
int yOffset = center.getY() - upperLeft.getY();
404405

405-
TouchAction action0 = new TouchAction(this).press(el, center.getX(), center.getY() - 100).moveTo(el).release();
406-
TouchAction action1 = new TouchAction(this).press(el, center.getX(), center.getY() + 100).moveTo(el).release();
406+
TouchAction action0 = new TouchAction(this).press(el, center.getX(), center.getY() - yOffset).moveTo(el).release();
407+
TouchAction action1 = new TouchAction(this).press(el, center.getX(), center.getY() + yOffset).moveTo(el).release();
407408

408409
multiTouch.add(action0).add(action1);
409410

@@ -448,9 +449,10 @@ public void zoom(WebElement el) {
448449
Dimension dimensions = el.getSize();
449450
Point upperLeft = el.getLocation();
450451
Point center = new Point(upperLeft.getX() + dimensions.getWidth() / 2, upperLeft.getY() + dimensions.getHeight() / 2);
452+
int yOffset = center.getY() - upperLeft.getY();
451453

452-
TouchAction action0 = new TouchAction(this).press(el).moveTo(el, center.getX(), center.getY() - 100).release();
453-
TouchAction action1 = new TouchAction(this).press(el).moveTo(el, center.getX(), center.getY() + 100).release();
454+
TouchAction action0 = new TouchAction(this).press(el).moveTo(el, center.getX(), center.getY() - yOffset).release();
455+
TouchAction action1 = new TouchAction(this).press(el).moveTo(el, center.getX(), center.getY() + yOffset).release();
454456

455457
multiTouch.add(action0).add(action1);
456458

0 commit comments

Comments
 (0)