Detox: Confirming system messages

Created on 11 Jul 2017  路  7Comments  路  Source: wix/Detox

Hey, great framewrok. I just got stuck on confirming alert message.
I have simple code:

Alert.alert('Great!', 'Now Check us out.', [
  { text: 'Continue', onPress: () => { this.handleContinue() } }
])

How do I confirm the dialog? Thanks a lot for your help.

questiostack overflow

Most helpful comment

Did you try to use text matcher?

await element(by.text('Continue')).tap();

All 7 comments

Did you try to use text matcher?

await element(by.text('Continue')).tap();

Element by text should work if I recall correctly.

This doesn't work if there is another element with the same label on the screen. Is there anything I can add to the matcher to make it more specific and only match the correct element?

@almost Not sure if this is still relevant, but for my case I used .and() with UIAlertControllerActionView to narrow it down.

https://stackoverflow.com/questions/47522081/detox-ios-simulator-how-to-confirm-alert-message

Hey there, I was trying to do the same, but using @anton6 didn't work for me now. Is there any other way to accomplish this? Thanks!

@jaumevn which iOS version? Do you know if it's the by.label or by.type part that fails to find the element?

@anton6 It fails in the by.label part, I'm using iOS 11.3 version.

Was this page helpful?
0 / 5 - 0 ratings