1

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 Answers1

1

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'));
Bartek Pacia
  • 1,085
  • 3
  • 15
  • 37
  • Thanks! Dump for subscribe: `````` I tried such a solution, but no success: ```'await tester.native.tap(Selector(pkg:'com.android.vending',className: 'android.widget.Button'));'``` – Agata Olbrycht Jun 29 '23 at 12:55
  • Currently, I updated to Patrol 2.0.0, and unfortunately I have a problem with new file test_bundle.dart it looks like import my test files doesn't work correctly. I back to the topic when I will be able to fix this. – Agata Olbrycht Jun 29 '23 at 12:58
  • That's sad to hear. Feel free to create an issue on GitHub, I'll do my best to help. – Bartek Pacia Jun 29 '23 at 14:33
  • on GitHub #1492. Thank you for help! – Agata Olbrycht Jul 10 '23 at 13:06