0

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

1 Answers1

0

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

valies
  • 96
  • 5
  • Thank you. I did see this documentation, but i just found out that there is important part not mentioned in the doc , the AppiumBy. must be imported first (from appium.webdriver.common.appiumby import AppiumBy) – Abdullah M. Adil Nov 22 '22 at 08:49
  • Imports are considered a given in most documentation I'm afraid. Great to read that you worked it out. Just remember that anytime your IDE does not recognise something, an import is missing. – valies Nov 22 '22 at 13:14