问题描述
我正在编写集成测试。我想点击滚动小部件内的按钮,该按钮从屏幕上是不可见的(至少在底部)。为了实现这一点,我正在编写如下代码,但无法正常工作。
SerializableFinder dashboardScrollView = find.byValueKey('dashboard_scroll_view');
SerializableFinder transfer = find.byValueKey('transfer');
test('open beneficiaries screen ',() async {
await scrollUntilVisible(dashboardScrollView,transfer);
await driver.tap(transfer);
});
Future<void> waitFor(SerializableFinder finder,{ Duration timeout }) async {
await sendCommand(WaitFor(finder,timeout: timeout));
}
Future<void> scroll(SerializableFinder finder,double dx,double dy,Duration duration,{ int frequency = 60,Duration timeout }) async {
await sendCommand(Scroll(finder,dx,dy,duration,frequency,timeout: timeout));
}
Future<void> scrollUntilVisible(
SerializableFinder scrollable,SerializableFinder item,{
double alignment = 0.0,double dxScroll = 0.0,double dyScroll = 0.0,Duration timeout,}) async {
assert(scrollable != null);
assert(item != null);
assert(alignment != null);
assert(dxScroll != null);
assert(dyScroll != null);
assert(dxScroll != 0.0 || dyScroll != 0.0);
bool isVisible = false;
waitFor(item,timeout: timeout).then<void>((_) { isVisible = true; });
await Future<void>.delayed(const Duration(milliseconds: 500));
while (!isVisible) {
await scroll(scrollable,dxScroll,dyScroll,const Duration(milliseconds: 100));
await Future<void>.delayed(const Duration(milliseconds: 500));
}
return scrollIntoView(item,alignment: alignment);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)