Detox icon indicating copy to clipboard operation
Detox copied to clipboard

How to interact with system alert dialogs

Open davidjonesdialexa opened this issue 3 years ago • 19 comments

Description

Our app calls a Cancel/Continue system alert dialog. The Matcher can't seem to locate the button to tap. Any ideas how to handle an element like this?

Screen Shot 2022-02-18 at 4 08 59 PM Screen Shot 2022-02-18 at 4 51 21 PM

Detox version

19.4.5

React Native version

0.66.3

Node version

No response

Device model

iphone 11

Xcode version

13.2.1

iOS version

15.2

macOS version

12.2.1

Android version

No response

Test runner

jest-circus

davidjonesdialexa avatar Feb 18 '22 22:02 davidjonesdialexa

Hi @davidjonesdialexa, unfortunately, Detox is not supporting interactions with system dialog, we are still working on this as part of XCUITest integration.

In the meanwhile, I can suggest to use a launch argument that will disable / fake the login while testing with Detox.

asafkorem avatar Feb 20 '22 15:02 asafkorem

@davidjonesdialexa As a work around maybe you can you try something like this:

element(by.label("Continue")).atIndex(0).tap();

cortisiko avatar Mar 07 '22 03:03 cortisiko

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

stale[bot] avatar Apr 06 '22 17:04 stale[bot]

@davidjonesdialexa As a work around maybe you can you try something like this:

element(by.label("Continue")).atIndex(0).tap();

Tried this but doesnt work.

activebiz avatar Apr 13 '22 20:04 activebiz

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

stale[bot] avatar May 25 '22 23:05 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Jun 11 '22 02:06 stale[bot]

Please what is the fix for this?

nero2009 avatar Sep 28 '22 13:09 nero2009

Is this still something that is being developed? Would be very helpful for a lot of projects I'm sure

sebbyrum avatar Oct 19 '22 17:10 sebbyrum

This works sometimes for me:

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

Where Continue is the text in the button you want to tap :)

sjors98 avatar Nov 16 '22 16:11 sjors98

Is there a fix for this issue? Thanks!

mariushorvat avatar Mar 08 '23 21:03 mariushorvat

Bump.

alfonsosn avatar Apr 12 '23 16:04 alfonsosn

Is there any development or workaround here? Finding elements by.text works in some cases but if there is a system alert on the screen nothing helps.

IvayloMetodiev avatar Jun 22 '23 14:06 IvayloMetodiev

I have the same problem, I can't fix this, Does anyone have an idea?

hoangtrunnam avatar Aug 23 '23 10:08 hoangtrunnam

Hi everyone, any update on this issue? How can we pass through this issue?

KaterinaUK avatar Sep 25 '23 09:09 KaterinaUK

This is absolutely required, cannot login without this.

codeyogi911 avatar Oct 05 '23 08:10 codeyogi911

@codeyogi911 you need to press the button on that dialog with your finger or mouse pointer. detox cannot catch that layout dialog

hoangtrunnam avatar Oct 05 '23 10:10 hoangtrunnam

_UIAlertControllerActionView

This is working fine for me on iOS simulator, but it doesn't for android emulator. I couldn't find an alternative for Android. Any solutions please ?

AbdelhakLabyadh avatar Dec 05 '23 15:12 AbdelhakLabyadh

_UIAlertControllerActionView

This is working fine for me on iOS simulator, but it doesn't for android emulator. I couldn't find an alternative for Android. Any solutions please ?

I think the UIDevice API can come in handy for Android (also check the reference there to the Android dev guide). I think techniques relying on DPadDown, DPadRight etc. could work best here.

You can try it out regardless of Detox in "playground" mode using ADB, with commands such as:

adb shell input keyevent KEYCODE_DPAD_DOWN

Please report back if you manage to sort that out 🙏🏻

d4vidi avatar Dec 11 '23 12:12 d4vidi

how is anyone ever building a useful test suite with this library 😢

phoet avatar Feb 27 '24 15:02 phoet

Support for system interactions was released with Detox v20.22

asafkorem avatar May 22 '24 15:05 asafkorem

Support for system interactions was released with Detox v20.22

Thank you for this functionality! Should it works with react-native Alert.alert ?

vomchik avatar Jun 14 '24 16:06 vomchik

Support for system interactions was released with Detox v20.22

Thank you for this functionality! Should it works with react-native Alert.alert ?

Thanks! Yes :)

asafkorem avatar Jun 16 '24 09:06 asafkorem

Support for system interactions was released with Detox v20.22

Thank you for this functionality! Should it works with react-native Alert.alert ?

Thanks! Yes :)

@asafkorem For some reason it's doesn't works for me CleanShot 2024-06-17 at 14 26 44@2x

I have tried both options: const button = system.element(by.system.label("Continue")); and const button = system.element(by.system.type("button")).atIndex(0);

Any ideas? 🤔

BTW, how DetoxXCUITestRunner knows which app we need to use for queries?

vomchik avatar Jun 17 '24 11:06 vomchik

CleanShot 2024-06-17 at 14 48 11@2x Is it ok to see this path not related to my local machine?

vomchik avatar Jun 17 '24 11:06 vomchik

I'm having the same issue that @vomchik reported. I tried the latest version 20.23.0 but I didn't see any difference. Any idea of what I may be missing? Thank you!

patriciazumo avatar Jun 19 '24 14:06 patriciazumo