How to tap by coordinates using appium in python

Viewed 11721

I got this error while attempting to tap by coordinates using appium in python:

AttributeError: 'list' object has no attribute 'id'

This is the code that I used:

from selenium import webdriver
from appium.webdriver.common.touch_action import TouchAction

caps = {}
caps["deviceName"] = "NVWCE6YSV47TGM8S"
caps["platformName"] = "Android"
caps["appPackage"] = "com.gradrix.quicklaunch"
caps["appActivity"] = "com.gradrix.quicklaunch.MainActivity"
driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)

time.sleep(5)
TouchAction(driver).tap([(104, 255)]).perform()
driver.quit()
2 Answers

It is working for me like this:

# None - don't know why is needed but as I want to tap at coordinates and not an element, is None
# 104  - X coordinate
# 255  - Y coordinate
# 1    - this is the time of the tap action
TouchAction(driver).tap(None, 104, 255, 1).perform()

Hope it helps and you get it working

Change

from selenium import webdriver

to

from appium import webdriver
Related