Accessibility ID


I have been tasked by my Mgr. to try see if one test can be run for both iOS and Adroind. For that he suggested I look up elements by accessibility identifier (Unless someone here can suggest something else).

If not…can someone tell me the best way to identify elements by accessibility ID…so that I can use the same test to run on both iOS and Android.?

@RamS what do you think? Or anyone else please feel free to respond.


Accessibility ID usually have text associated with element. These texts might change over a period of time and will break the script. Since the text would be common for application [platform independent], if it breaks, it breaks for both Android and iOS. One fix ideally should fix for both. Only thing I would like to highlight is, ensure these values are unique.

I am a great fan of ID field :wink: If we can write a wrapper that takes care of abstracting ID and define mechanism to identify which attribute of UIElement to check during run time based on platform, will do the job better :slight_smile:

Basically what I need to do is see if I can write one test script that identifies elements by Accessibility identifier (both ios and android). This script, if run, should run for both ios and android. First of all this will not be possible for all screens since some of the screens may be different right? Secind question: even for elements across ios and android that have the same accessibility identifier would it work…given that both platforms have their own drivers nd hence same code cannot be used for both? If it is still possible please tell me how that would be possible, and how to get accessibility Identifier of elemebt using appium (or however). Would greatly appreciate an example.

Thanks plead let ke know if You need more clarification.


Its possible as we have a framework which comes close to this solution.
But it does take good amount of efforts.

In brief we have a framework which generates generic Page objects for each page in your app. These page objects provide very generic apis for page elements [Ex : setFirstName for edittext. Internally it might be identified by platform specific findBy ]
Factory which returns the respective drivers at run time for each platform.


As in is there a built-in framework with Appium or do I need to build on ? But lets say I have a Page Object Model framework where one class is for the Home Page (should this class capture elements for both iOS and Android?)…and then similarly another class for Login Page or something.

I can then have these objects called…but still still my main question is: the drivers will be different in each case right ? I don’t see how we can accomplish all of that with just one driver for both platforms…unless you can cite an example.


I have the same requirement with you. And my solution is define one super testcase class, in this class I have a flag to confirm which driver to use the code like:

public static boolean ANDROID_PLATFORM = true;

capabilities.setCapability(“unicodeKeyboard”, “True”);
capabilities.setCapability(“resetKeyboard”, “True”);
driver = new AndroidDriver(new URL(“”),
capabilities.setCapability(“deviceName”, “iPhone 6”);
driver = new IOSDriver(new URL(“”),

@RamS: Can you elaborate more on writing a ‘wrapper class that takes care of abstracting ID and defining mechanism to identify attribute of UIElement?’.I need to do a similar thing in my project.

How can I see the Accessibility ID on the inspector? I know that my dev team is using accessibilityIDs but I don’t see any property on the Inspector named Accessibility ID, does anybody used this before? I want to use it because findElementByName will be deprecated and instead of name we should use accessibilityID.

1 Like

In most cases it is “name” attribute.

1 Like

try: driver.findElement(MobileBy.AccessibilityId(“name here”))


before try you need to know what to try :-). in most cases “AccessibilityID” is visible as “name” attribute in inspector.

1 Like

not that “try”. I meant attempt that piece of code =)