Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tap behaviour not consistent when using disableSynchronization #1499

Closed
denissb opened this issue Jul 2, 2019 · 1 comment
Closed

tap behaviour not consistent when using disableSynchronization #1499

denissb opened this issue Jul 2, 2019 · 1 comment

Comments

@denissb
Copy link
Contributor

denissb commented Jul 2, 2019

Hello everyone

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 synchronisation, so I have to synchronise 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 synchronise with that screen so I am using tap to press on the button with synchronisation 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.

Can anyone recommend a workaround or knows what the problem is?

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

Environment:

Detox: 12.10.3.
React Native: 0.59.8
Node: v11.7.0
Device: iOS Emulator (iPhone 8)
OS: iOS

@support
Copy link

support bot commented Jul 2, 2019

We use the issue tracker exclusively for bug reports and feature requests. This issue appears to be a general usage or support question. Instead, please ask a question on Stack Overflow with the detox tag.
Feel free to post your Stack Overflow question here for more visility. We'll take a look at it.
For more information on bots in this reporsitory, read this discussion.

@support support bot closed this as completed Jul 2, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jul 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant