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

huangapple go评论76阅读模式
英文:

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

问题

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'));
    });
  });
}

Thank you for your help!

英文:

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

得分: 1

我建议您在屏幕上看到“Subscribe”按钮时获取视图层次结构转储(在测试运行时不要执行此操作):

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

然后在某个代码编辑器中打开window_dump.xml文件,使用CTRL+F查找“Subscription”,看看按钮是否在那里可见。也许text属性未设置,但contentDescription设置了?所以您可以尝试:

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

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'));

huangapple
  • 本文由 发表于 2023年6月26日 21:14:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76557039.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定