I am self learning Appium with Python, but unable to execute TouchAction as I'm facing error
KeyError: 'touchAction'.
Here are the details:
Code:
from appium.webdriver.common.touch_action import TouchAction
from selenium import webdriver
# Define desired capabilities
desired_caps = {
"deviceName": "ac******",
"platformName": "Android",
"appPackage": "com.android.dialer",
"noReset": "true",
"appActivity": "com.oneplus.contacts.activities.OPDialtactsActivity"
}
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)
driver.implicitly_wait(20)
# Locators and actions
user_action = TouchAction(driver)
user_action.tap(x=909, y=220).perform()
Logs in PyCharm:
C:\Users\PycharmProjects\AppiumSandbox\venv\Scripts\python.exe C:/Users/PycharmProjects/AppiumSandbox/tests/contactone.py
Traceback (most recent call last):
File “C:/Users/PycharmProjects/AppiumSandbox/tests/contactone.py”, line 21, in
user_action.tap(x=909, y=220).perform()
File “C:\Users\PycharmProjects\AppiumSandbox\venv\lib\site-packages\appium\webdriver\common\touch_action.py”, line 149, in perform
self._driver.execute(Command.TOUCH_ACTION, params)
File “C:\Users\PycharmProjects\AppiumSandbox\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py”, line 319, in execute
response = self.command_executor.execute(driver_command, params)
File “C:\Users\PycharmProjects\AppiumSandbox\venv\lib\site-packages\selenium\webdriver\remote\remote_connection.py”, line 367, in execute
command_info = self._commands[command]
KeyError: ‘touchAction’
Logs in Appium:
[HTTP] --> POST /wd/hub/session/f509a834-5b7e-4354-89d5-00dd4a59666d/timeouts
[HTTP] {“implicit”:20000}
[W3C (f509a834)] Calling AppiumDriver.timeouts() with args: [null,null,null,null,20000,“f509a834-5b7e-4354-89d5-00dd4a59666d”]
[BaseDriver] W3C timeout argument: {“implicit”:20000}}
[BaseDriver] Set implicit wait to 20000ms
[W3C (f509a834)] Responding to client with driver.timeouts() result: null
Issue got resolved by adding from appium import webdriver
and removing from selenium import webdriver
under mentioned Automation script.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.