LoreC
October 16, 2024, 11:51am
1
How can I update the following code using w3c actions to perform a 4 finger tap since TouchAction and MultiTouch are now deprecated and can no longer be used.
In Python, please!!
x = scl.window_size['width']
y = scl.window_size['height']
multi_touch = TouchAction(self.driver)
multi_touch.press(x=.5 * x, y=.5 * y).press(x=.6 * x, y=.5 * y).press(x=.7 * x, y=.5 * y).press(x=.8 * x, y=.5 * y).release().perform()
example with 2 which you can extend to 4
// tap to point 1
Point point1 = new Point(rectangle.x + (rectangle.width / 2), rectangle.y + (rectangle.height / 2));
PointerInput finger1 = new PointerInput(PointerInput.Kind.TOUCH, "finger");
Sequence tapSeq1 = new Sequence(finger1, 1);
tapSeq1.addAction(finger.createPointerMove(Duration.ofMillis(0), PointerInput.Origin.viewport(), point1.x, point1.y));
tapSeq1.addAction(finger.createPointerDown(PointerInput.MouseButton.LEFT.asArg()));
tapSeq1.addAction(finger.createPointerMove(Duration.ofMillis(50), PointerInput.Origin.viewport(), point1.x, point1.y));
tapSeq1.addAction(finger.createPointerUp(PointerInput.MouseButton.LEFT.asArg()));
// tap to point 2
Point point2 = new Point(rectangle.x + (rectangle.width / 2), rectangle.y + (rectangle.height / 2));
PointerInput finger2 = new PointerInput(PointerInput.Kind.TOUCH, "finger");
Sequence tapSeq2 = new Sequence(finger2, 1);
tapSeq2.addAction(finger.createPointerMove(Duration.ofMillis(0), PointerInput.Origin.viewport(), point2.x, point2.y));
tapSeq2.addAction(finger.createPointerDown(PointerInput.MouseButton.LEFT.asArg()));
tapSeq2.addAction(finger.createPointerMove(Duration.ofMillis(50), PointerInput.Origin.viewport(), point2.x, point2.y));
tapSeq2.addAction(finger.createPointerUp(PointerInput.MouseButton.LEFT.asArg()));
driver.perform(Arrays.asList(tapSeq1, tapSeq2));
LoreC
October 16, 2024, 1:09pm
3
Thanks, but I need it in Python.
LoreC
October 21, 2024, 8:10am
4
@mykola-mokhnach , could you guide me, please?
I tried to use:
e = driver.find_element(AppiumBy.ACCESSIBILITY_ID, 'element')
driver.execute_script("mobile: tapWithNumberOfTaps", {"elementId": e, "numberOfTaps": 1, "numberOfTouches": 4})
but it didn’t work.