Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在python中使用appium按坐标点击_Android_Python 2.7_Coordinates_Appium - Fatal编程技术网

Android 如何在python中使用appium按坐标点击

Android 如何在python中使用appium按坐标点击,android,python-2.7,coordinates,appium,Android,Python 2.7,Coordinates,Appium,我在python中使用appium尝试按坐标点击时遇到此错误: AttributeError:“列表”对象没有属性“id” 这是我使用的代码: from selenium import webdriver from appium.webdriver.common.touch_action import TouchAction caps = {} caps["deviceName"] = "NVWCE6YSV47TGM8S" caps["platformName"] = "Android" ca

我在python中使用appium尝试按坐标点击时遇到此错误:

AttributeError:“列表”对象没有属性“id”

这是我使用的代码:

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

它对我来说是这样的:

# 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()
希望它能帮助你,让它工作起来

改变

from selenium import webdriver


你有一个很好的计划。我不知道人们为什么要关闭此操作。请尝试
触摸操作(驱动程序)。点击(x=104,y=255)。执行()
tap
需要两个关键字而不是一个列表。@Maximilian我更改了参数
。点击(x=104,y=255)
而不是
。点击([(104,255)])
我得到了:keyrerror:“touchAction”。
from appium import webdriver