appium / java-client

Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol
Apache License 2.0
1.19k stars 752 forks source link

Added composeTestTag property to AndroidFindBy annotation #2165

Closed devapro closed 2 months ago

devapro commented 2 months ago

Change list

Added composeTestTag property to AndroidFindBy annotation. This property makes simple writing tests for android Compose UI

Types of changes

What types of changes are you proposing/introducing to Java client? Put an x in the boxes that apply

Details

Android Compose UI by default provide test tag for testing. However, it doesn't work out the box in the Appium.

For example:

// Compose view
 IconButton(
            modifier = Modifier.semantics {
                testTag = "somTestTag"
            },
            onClick = {.... }
        ) {
        .....
// Appium page object

  @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"somTestTag\")")
    protected WebElement iconButton;

With changes from this PR, code will be simplified:

@AndroidFindBy(composeTestTag = "somTestTag")
    protected WebElement iconButton;
linux-foundation-easycla[bot] commented 2 months ago

CLA Signed


The committers listed above are authorized under a signed CLA.

shero commented 2 months ago

Great PR 👍 I think, you also need to update public @interface AndroidBy {} with the composeTestTag as well