# Get access to string resources in UiAutomator

DevFeed: [Get access to string resources in UiAutomator](<https://devfeed.tech/articles/get-access-to-string-resources-in-uiautomator-24845.md>)

Original publisher: [Read original article](<https://alexzh.com/get-access-to-string-resources-in-uiautomator/>)

Author: Alex Zhukovich

Published: 2023-03-24T17:21:14Z

Content type: tutorial

Language: en

Sources: [Alex Zhuk](<https://devfeed.tech/sources/alex-zhuk-android-development-and-testing.md>)

Topics: [UiAutomator](<https://devfeed.tech/topics/uiautomator.md>), [Web Accessibility (a11y)](<https://devfeed.tech/topics/web-accessibility.md>)

Tags: [accessibility](<https://devfeed.tech/tags/accessibility.md>), [application](<https://devfeed.tech/tags/application.md>), [compilation](<https://devfeed.tech/tags/compilation.md>), [compilation-error](<https://devfeed.tech/tags/compilation-error.md>), [context](<https://devfeed.tech/tags/context.md>), [device](<https://devfeed.tech/tags/device.md>), [dialog](<https://devfeed.tech/tags/dialog.md>), [espresso](<https://devfeed.tech/tags/espresso.md>), [example](<https://devfeed.tech/tags/example.md>), [failure](<https://devfeed.tech/tags/failure.md>), [formatting](<https://devfeed.tech/tags/formatting.md>), [framework](<https://devfeed.tech/tags/framework.md>), [function](<https://devfeed.tech/tags/function.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [id](<https://devfeed.tech/tags/id.md>), [language](<https://devfeed.tech/tags/language.md>), [resources](<https://devfeed.tech/tags/resources.md>), [string](<https://devfeed.tech/tags/string.md>), [test](<https://devfeed.tech/tags/test.md>), [ui-testing](<https://devfeed.tech/tags/ui-testing.md>), [uiautomator](<https://devfeed.tech/tags/uiautomator.md>)

## AI overview

The excerpt recommends replacing hard-coded notification text in UiAutomator tests with values loaded from the app's string resources, helping tests tolerate locale changes and resource text updates. It describes two approaches: look up a resource by passing the package name and resource ID as strings, which is typo-prone, or use the generated resource class. The latter requires application context, obtained from the test context, and a helper that returns the string for a resource ID. Reusing resources provides a single source of truth and lets compilation catch renamed resource identifiers. The excerpt omits the actual API and class names and code, so it does not provide implementation details.

## Source excerpt

This article explains how to access string resources in UiAutomator test cases.