appiumui-automationappium-androidandroid-uiautomatorappium-ios

How to get elementid attribute of a node from appium programatically?


In Appium inspector when you hover over a selected element, there is an elementId attribute. Is there any way I can get this elementId programatically maybe generate it from the xml tree or adb shell commands.

enter image description here

Also, I found very scarce information on elementId attribute. It would also be great to know if someone can share what is elementId and how it is generated by the appium driver. Thanks


Solution

  • I believe 'elementId' is generated dynamically by iOS so won't really be of much use to you. It would be best to stick to 'name', 'label', 'value' and 'type' when searching for elements.

    See here for finding elements: https://appium.io/docs/en/commands/element/find-elements/

    iOS findElementsByIosNsPredicate can be quite powerful and useful e.g. from your screen shot:

    findElementsByIosNsPredicate("label == 'save' AND name == 'save' AND type == 'XCUIElementTypeButton'")