首页 > 解决方案 > Flutter 驱动程序与原生元素交互

问题描述

我很难使用 Flutter Driver 进行测试,我认为这可能是一个限制,问题是因为我无法与原生元素交互,我的意思是,我正在使用 Google 构建登录,并且在调用函数后iOS它显示一个确认登录的对话框

在此处输入图像描述

但是在集成测试中我不知道如何与之交互

final buttonLoginFinder = find.byValueKey('login_button');
final buttonContinueFinder = find.text('Continue');
// ...

await driver.tap(buttonLoginFinder);
await driver.waitFor(buttonContinueFinder);
await driver.tap(buttonContinueFinder);

标签: iosflutterflutter-test

解决方案


从我的角度来看,这不是测试您的应用程序的正确方法。Google 登录应被视为一个黑匣子。因此,在集成测试期间,应该对其进行模拟,并在尝试登录而无需特定对话交互时仅返回真/假。这样,您可以假设 Google Sign In 作为第三方库正常工作,并跳过外部组件的集成测试。


推荐阅读