Flutter> Patrol > Mobile automatization test: How to access to "Subscribe" button on system pop-up Google Play Store?

287 Views Asked by At

I'm trying to purchase a subscription in my tests. Everything goes well until the native Android purchase popup appears. I'm not able to tap on the green 'Subscribe' button. Is there a way to do it? The following code doesn't work:

** See screenshot - which button is the problem **

void main() async { 
  group('App', ()   {

    patrolTest('Buy Subscription', nativeAutomation: true, ( PatrolTester tester) async {

      await app.main();
      await tester.pumpAndSettle();
      await tester(ElevatedButton).tap();
      await tester.native.tap(Selector(text: 'Subscribe'));    });}); }

Thanks you for your help!

1

There are 1 best solutions below

4
On

I suggest you take a view hierarchy dump while you see the "Subscribe" button on-screen (you mustn't to do it while the test is running):

adb shell uiautomator dump && adb pull /sdcard/window_dump.xml .

Then open the window_dump.xml file in some code editor, CTRL+F for "Subscription" and see if the button is visible there. Maybe the text attribute is not set, but contentDescription is? So you could try doing:

await tester.native.tap(Selector(contentDescription: 'Subscribe'));