首页 > 解决方案 > Detox IOS - 由于连续动画错误导致测试失败,disableSynchronization 不起作用

问题描述

请多多包涵,我是排毒新手!我目前正在评估 Detox 作为一种众所周知的非常慢的黑盒自动化工具的替代品!

环境噪声

使用执行测试: detox test --debug-synchronization --loglevel trace

我正在编写一个登录到我们的应用程序并验证登录页面的自动化测试。登录后,我无法识别任何元素,因为我得到的错误是:

"appState": "Waiting for an animation to finish. Continuous animations may never finish and must be stopped explicitly. Animations attached to hidden view may still be running in the background.\nWaiting for view's draw or layout pass to complete."

detox[94060] INFO:  [actions.js] Sync Timed: 
animateWithDuration:delay:options:animations:completion:
detox[94060] INFO:  [actions.js] Sync Timed: performSelector 
@selector(removeInactiveFingerTips) on DTXTouchVisualizerWindow
detox[94060] INFO:  [actions.js] Sync App State: undefined
detox[94060] INFO:  [actions.js] Sync Dispatch Queue: com.apple.main- 
thread
detox[94060] TRACE: [AsyncWebSocket.js/WEBSOCKET_MESSAGE] 
{"type":"cleanupDone","messageId":8,"params":{}}

我已将 URL 添加到黑名单中,这有助于消除一些错误,现在我已经将我的步骤包含在许多组合中,device.disableSynchronizationdevice.enableSynchronization这似乎没有帮助。请查看我当前的测试版本:

describe('Signon and browse', () => {
beforeEach(async () => {
  await device.reloadReactNative();
});

 it('I log into the app', async () => {
     await element(by.id('input_username')).replaceText('mysername');
     await element(by.id('input_password')).replaceText('mypassword');
     await element(by.id('button-signon')).tap();
     await device.disableSynchronization();
     await waitFor(element(by.id('app-title'))).toHaveValue('DISCOVER').withTimeout(20000);
     await device.enableSynchronization();
 })
});

我是一名测试自动化开发人员,而不是应用程序的 ReactNative 开发人员,因此我不确定在实际的 ReactNative 代码中是否需要更改某些内容 - 这对我们来说将是一个大问题!

谢谢你的帮助。

标签: detox

解决方案


从 Detox 文档中waitFor()toHaveValue()应附有expect声明。https://github.com/wix/detox/blob/master/docs/APIRef.waitFor.md#tohavevaluevalue

如下图expect()后添加。waitFor()

await waitFor(element(by.id('app-title'))).toHaveValue('DISCOVER').withTimeout(20000);
await expect(element(by.id('app-title'))).toHaveValue('DISCOVER');

推荐阅读