Hi!
I need to find a way to click on specific coordinates. Not getting them from element - because there is no element, just need to click X, Y coordinates.
Using: iOS, Python
Thank you !
I dont use python, but have you checked:
opened 06:59PM - 23 Mar 15 UTC
closed 12:06AM - 28 Nov 18 UTC
In trying to dismiss the soft keyboard after a `.clear()` without resetting the … session's keyboard setting (i.e. `hide_keyboard` is a no go), I thought I'd be clever and use `TouchAction` like this to tap just outside of the element that had displayed the soft keyboard:
```
def dismiss_keyboard(element):
elem_x = element.location['x']
elem_y = element.location['y']
# Find average x-value between left edge of app and left edge of element
benign_x = (elem_x - 0) / 2
# Tap between element and edge of app to dismiss soft keyboard
action = TouchAction(self.driver)
action.move_to(
benign_x, elem_y).press(
x=benign_x, y=elem_y).release().perform()
```
But, of course, not clever, because both press() and tap() require an element:
```
Traceback (most recent call last):
File "/Users/kraymoure/repos/r64/qa/tests/mobile/test_ios_environments.py", line 53, in setUp
self.clear_search()
File "/Users/kraymoure/repos/r64/qa/tests/mobile/ios_base.py", line 272, in clear_search
self.dismiss_soft_keyboard(search_input)
File "/Users/kraymoure/repos/r64/qa/tests/mobile/ios_base.py", line 295, in dismiss_soft_keyboard
benign_x, search_y).press(
File "/Library/Python/2.7/site-packages/appium/webdriver/common/touch_action.py", line 79, in move_to
self._add_action('moveTo', self._get_opts(el, x, y))
File "/Library/Python/2.7/site-packages/appium/webdriver/common/touch_action.py", line 118, in _get_opts
opts['element'] = element.id
AttributeError: 'int' object has no attribute 'id'
```
TouchAction already supports supplying None for the element (and other arguments).
E.g.: action.press(el=None, x=None, y=None)
2 Likes
Thanks a lot, your link helped me
I was using such code:
self.driver.tap(128.90625, 335.90625) without success
but the right one example:
self.driver.tap([(128.90625, 335.90625 )])
so you have to use array of coordinates, even if there is just one coordinate.
Thanks! Now its working!
1 Like