Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Not able to locate and select primary button in Payment Sheet via automation #9624

Open
alabrecq opened this issue Nov 14, 2024 · 4 comments
Labels

Comments

@alabrecq
Copy link

Summary

We use PaymentSheet.FlowController in our app. We recently updated the Stripe SDK from version 2.48.0 to a more up to date version (tested up to 21.0.1) and have run into an issue.

For some background info: we have end-to-end tests using Appium that we run our app through, and that includes opening and submitting a payment in test mode using this Flow Controller.

The issue is even though we are able to locate and manipulate all of the elements to enter a test card number, expiration date, security code, and zip code, the primary button to confirm payment method on the bottom sheet is not locatable in Appium after updating the Stripe SDK. We recognize this could be an automation issue, but this only occurs after the Stripe SDK upgrade so we thought to inquire here.

Here is a screenshot of the inspected view hierarchy in version 2.48.0, where the primary button is reflected:

20 48 0 has-confirm-button-for-automation

Here is a screenshot of the inspected view hierarchy in version 20.53.0 (same result with 21.0.1), where the primary button is not reflected (even though it is on screen and interact-able):

20 53 0 missing-confirm-button-for-automation

Our question is - is there anything that can be thought of that might explain the change in the UI inspectability of this button, and any way to gain back the ability to locate it in Appium?

This issue prevents us from completing automated payment tests, which is critical for our release process. Thank you in advance.

Code to reproduce

Payment sheet creation is pretty straightforward using FlowController and no changes to this code were needed in the SDK upgrade:

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)
    paymentFlowController = PaymentSheet.FlowController.create(
        fragment = this,
        { paymentOption -> /* */ },
        { result -> /* */ }
    )
    /* */
}

private fun configurePaymentSheet(clientSecret: String) {
    paymentFlowController.configureWithPaymentIntent(
        clientSecret,
        PaymentSheet.Configuration(
            merchantDisplayName = /* */,
            primaryButtonLabel = /* */,
            allowsDelayedPaymentMethods = true,
            appearance = PaymentSheet.Appearance(
                /* */
            )
        ),
    ) { isReady, error ->
        /* Enables access to payment sheet via clickPaymentMethod */
    }
}

private fun clickPaymentMethod() {
    paymentFlowController.presentPaymentOptions()
}

Android version

Across all versions of Android.

Impacted devices

None in particular.

Installation method

Through the Gradle dependency.

Dependency Versions

Kotlin: 1.9.0
stripe-android: 20.53.0
Android Gradle Plugin: 8.6.1
Gradle: 8.7

SDK classes

PaymentSheet.FlowController

Additional info

We've tried a couple of methods for looking for the button in our test script:
xpath: //android.widget.TextView[@text="Confirm payment"]
id: [package]:id/primary_button

@alabrecq alabrecq added the bug label Nov 14, 2024
@jaynewstrom-stripe
Copy link
Collaborator

Internally we're using compose test utilities to drive this via automation.

You can see the buy button click here.

And you can also see the test tag used here.

We've not tried appium, but if there's something we can change to make driving it easier, let me know.

@alabrecq
Copy link
Author

Thanks for the quick reply. The one thing I have read as far as testing Compose UI with Appium/UIAutomator is to set testTagsAsResourceId = true somewhere in the composable hierarchy. https://discuss.appium.io/t/does-appium-support-jetpack-compose-app-automation/40884/5

I'm not sure if that's already the case here, but it is one thing I thought might be worth trying.

@jaynewstrom-stripe
Copy link
Collaborator

This PR doesn't break any of our tests! #9632

Would you be willing to try it with composite builds?

To see if it fixes the issue?

@alabrecq
Copy link
Author

Thank you for this! I'm a bit stuck on the composite build setup, but I will give it a closer look early next week and reply back soon after. Sorry for the delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants