I have a test which uses a WebView to login to the application (done in a hacky way by using a text input with a button + injectedJavaScript
as WebView instrumentation is not supported).
The problem appears because the login operation inside the WebView happens asynchronously and breaks the Detox synchronization, so I have to manage it myself manually with disableSynchronization
and enableSynchronization
.
After the login I have a stack transition animation to a new screen (from react-navigation) and I need to press a button on that screen to go further. However Detox still fails to synchronize with that screen so I am using tap to press on the button with synchronization disabled.
This is where the problem happens, the tap doesn't always work, and in 50% of the time just fails with a timeout for any action done after the disableSynchronization
call. This makes the tests flaky and pretty much useless
Can anyone recommend a workaround or knows what the problem is?
Environment Detox: 12.10.3. React Native: 0.59.8 Node: v11.7.0 Device: iOS Emulator (iPhone 8) OS: iOS
I tried disabling and enabling the synchronisation before and after the tap on the button but it did not help, and in fact made the test fail with a timeout.
The code of my login method:
export const loginAs = async (userID) => {
await element(by.id('introLoginBtn')).tap();
await expect(element(by.id('loginScreen'))).toBeVisible();
const userIdInput = element(by.id('testUserIdInput'));
await userIdInput.tap();
await userIdInput.typeText(userID);
await element(by.id('testLoginBtn')).tap();
// NOTE: WebView login breaks synchronization see
// https://github.com/wix/Detox/blob/master/docs/Troubleshooting.Synchronization.md
await device.disableSynchronization();
// Waiting for the element to be visible
await waitFor(element(by.id('acceptTermsBtn'))).toBeVisible().withTimeout(9000);
// This does not work consistently
await element(by.id('acceptTermsBtn')).tap();
await device.enableSynchronization();
};
When I get in the debug console with --debug-synchronization 200
:
detox[33941] INFO: [actions.js] Sync Timer: Tracking Timer <__NSCFTimer: 0x600003e6de00>
detox[33941] INFO: [actions.js] Sync Timed: performSelector @selector(removeInactiveFingerTips) on DTXTouchVisualizerWindow
detox[33941] INFO: [actions.js] Sync Timed: animateWithDuration:delay:options:animations:completion:
detox[33941] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[33941] INFO: [actions.js] Sync App State: undefined
detox[33941] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[33941] INFO: [actions.js] Sync Timed: performSelector @selector(removeFromSuperview) on COSTouchSpotView
detox[33941] INFO: [actions.js] Sync Timed: animateWithDuration:delay:options:animations:completion:
detox[33941] INFO: [actions.js] Sync Timed: performSelector @selector(removeInactiveFingerTips) on DTXTouchVisualizerWindow
detox[33941] INFO: [actions.js] Sync Timed: animateWithDuration:delay:options:animations:completion:
detox[33941] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[33941] INFO: [actions.js] Sync App State: undefined
detox[33941] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[33941] INFO: [actions.js] Sync Timed: performSelector @selector(removeInactiveFingerTips) on DTXTouchVisualizerWindow
detox[33941] INFO: [actions.js] Sync Timed: performSelector @selector(removeFromSuperview) on COSTouchSpotView
detox[33941] INFO: [actions.js] Sync Timed: animateWithDuration:delay:options:animations:completion:
detox[33941] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[33941] INFO: [actions.js] Sync App State: undefined
detox[33941] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[33941] INFO: [actions.js] Sync Timed: performSelector @selector(removeInactiveFingerTips) on DTXTouchVisualizerWindow
detox[33941] INFO: [actions.js] Sync Timed: performSelector @selector(removeFromSuperview) on COSTouchSpotView
detox[33941] INFO: [actions.js] Sync WXAnimatedDisplayLinkIdlingResource: undefined
detox[33941] INFO: [actions.js] Sync App State: undefined
detox[33941] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[33941] INFO: [actions.js] Sync Timed: performSelector @selector(removeInactiveFingerTips) on DTXTouchVisualizerWindow
detox[33941] INFO: [actions.js] Sync WXAnimatedDisplayLinkIdlingResource: undefined
detox[33941] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[33941] INFO: [actions.js] Sync WXAnimatedDisplayLinkIdlingResource: undefined
detox[33941] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[33941] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[33941] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[33941] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[33941] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[33941] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[33941] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[33941] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
The last 3 lines repeat until the test times out.
and after launching withlaunchArgs: { 'detoxPrintBusyIdleResources': 'YES' }
and running xcrun simctl spawn booted log stream --level debug --style compact --predicate "category=='EarlGreyStatistics'"
:
Error from getpwuid_r: 0 (Undefined error: 0)
Filtering the log data using "category == "EarlGreyStatistics""