Luis Peyote
Luis Peyote

Reputation: 51

How to tap by coordinates using appium in python

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()

Upvotes: 4

Views: 17925

Answers (2)

Anatoliy Strilets
Anatoliy Strilets

Reputation: 11

Change

from selenium import webdriver

to

from appium import webdriver

Upvotes: 1

barbudito
barbudito

Reputation: 578

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

Upvotes: 6

Related Questions