Detox: iOS Simulator How to Confirm Alert Message

Detox: iOS Simulator how to confirm alert message

After some tinkering I ended up using this:

await element(by.label('Log out').and(by.type('_UIAlertControllerActionView'))).tap();

Not sure if this will work for every iOS version, but seem to work on 10.3 and 11.1

Use View Hierarchy Debugger provided by Xcode to see if the type has changed for a different version of iOS.

How do I control the alert use detox in iOS?

I have been able to do the following to tap on a native iOS alert.

await element(by.label('OK').and(by.type('_UIAlertControllerActionView'))).tap();

I got the solution from here Detox: iOS Simulator how to confirm alert message

How to click this dialog with Detox? Obvious solution but I still can't tap it

Detox uses applesimutils to set permissions. This is battle tested in production at Wix and in Detox CI. Check out the docs and test project for examples.

How to tell Detox to wait for my elements to appear

You can use the waitFor function with a timeout you define:

await waitFor(element(by.id('my-view'))).toBeVisible().withTimeout(5000)

this tells detox to wait 5000ms before failing.

See example here: https://github.com/wix/Detox/blob/master/docs/Troubleshooting.RunningTests.md#test-tries-to-find-my-component-before-its-created



Related Topics



Leave a reply



Submit