Search code examples
androidautomationappiumui-automationandroid-uiautomator

NameError: Global name 'TouchAction' is not defined in android automation by appium python


While performing this code for automating android app using appium python client,

el = self.driver.find_element_by_accessibility_id('Hello')
action = TouchAction(self.driver)
action.tap(el).perform()

Its giving error saying "NameError: global name 'TouchAction' is not defined". What am I missing?


Solution

  • You have to add the import package at the beginning:

    from appium.webdriver.common.touch_action import TouchAction