pythonpython-appium

Appium-python-client, find element function


im new to the appium library and I'm facing issues with the methods to locate elements in an android app, the two methods in question are: 1- driver.find_element_by_id 2- driver.find_element

#desired_cap defined above
driver = web.driver.remote("http://localhost:4723/wd/hub", desired_cap)
driver.find_element_by_id(#element id)

the problem is i can't find this method. when i type it in the ide it doesn't work. I tried using the find_element method but it didn't work too.

desired_cap = {
  "appium:deviceName": "emulator-5554",
  "appium:appActivity": ".LandingScreen",
  "platformName": "Android",
  "appium:appPackage": "com.myapp",
  "appium:noReset": "true"
}
driver = webdriver.Remote("http://localhost:4723/wd/hub",desired_cap)

driver.find_element("AppiumBy.ID","com.talabat:id/ivToolbarAddressArrow")

i tried to make the second method work: "AppiumBy.ID" By.ID ID "id" none of them made the duntion work


Solution

  • First of all, I believe you have a typo and it should read webdriver iso web.driver:

    driver = webdriver.remote("http://localhost:4723/wd/hub", desired_cap)
    

    To answer your question: Appium works with accessibility ID, like so:

    driver.find_element("AppiumBy.ACCESSIBILITY_ID","SomeAccessibilityID")
    

    Appium documentation here