Search code examples
pythonseleniumgoogle-chromemobiletouch

How do I tap coordinates inside of a specific element with selenium TouchActions python?


The Selenium ActionChains module includes the ability to move to an element with offset provided an x and y coordinate like so: ActionChains(browser).move_to_element_with_offset(x-offset, y-offser).click().perform() Which is useful to test responsiveness of elements nested inside other elements such as a react element.

The Selenium TouchActions module includes something similar except the coordinates are relative to the viewport. My TouchActions script looks like this:

TouchActions(browser).tap_and_hold(x-offset, y-offset).release(x-offset, y-offset).perform()

This script does not activate the expected event for me; however, this script does:

element = browser.find_element_by_XPath(//img)
TouchActions(browser).tap(element).perform()

The tap occurs at the center of the element, which is useful; however, I need the ability to repeat the tap again at different parts of the element to test for the event. ADDITIONAL NOTE: The expected events can be fired manually.


Solution

  • It turns out that the implementation of the app i was working on had a feature that was accessible via the native os version, but not via its web version.

    This question could have been solved easier if i had provided details of the specific application I was trying to test.

    The provided uses of Selenium in the question work fine. Here's the documentation