Search code examples
react-nativedetox

I can not answer the native iOS confirm Detox - mocha application in React native


I just started using Detox to test my react native app and I'm having some trouble to answer for native confirm.

I didnt find list of _UI......View (like: _UIAlertControllerActionView, _UINavigationBarBackIndicatorView)

it('should show world screen after tap', async () => {

    await loginPage.getFbBtn().tap();    
    // await element(by.type('_UINavigationBarBackIndicatorView')).tap(); 
    //await element(by.text('Continue')).tap();
    await element(by.text('Continue').and(by.type('_UIAlertControllerActionView'))).tap();
  });

element(by.type('_UINavigationBarBackIndicatorView')).tap();

(node:2009) UnhandledPromiseRejectionWarning: Error: Cannot find UI element. Exception with Action: { "Action Name": "Tap", "Element Matcher": "((!(kindOfClass('RCTScrollView')) && kindOfClass('(null)')) || (((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && parentThatMatches(kindOfClass('RCTScrollView'))) && ((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && parentThatMatches(kindOfClass('(null)')))))", "Recovery Suggestion": "Check if the element exists in the UI hierarchy printed below. If it exists, adjust the matcher so that it accurately matches element." }

Error Trace: [ { "Description": "Interaction cannot continue because the desired element was not found.", "Error Domain": "com.google.earlgrey.ElementInteractionErrorDomain", "Error Code": "0", "File Name": "GREYElementInteraction.m", "Function Name": "-[GREYElementInteraction matchedElementsWithTimeout:error:]", "Line": "124" } ]

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

Error: Cannot find UI element. Exception with Action: { "Action Name": "Tap", "Element Matcher": "((!(kindOfClass('RCTScrollView')) && (((kindOfClass('UILabel') || kindOfClass('UITextField') || kindOfClass('UITextView')) && hasText('Continue')) || (kindOfClass('RCTTextView') && an object with accessibilityLabel "Continue"))) || (((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && parentThatMatches(kindOfClass('RCTScrollView'))) && ((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && parentThatMatches((((kindOfClass('UILabel') || kindOfClass('UITextField') || kindOfClass('UITextView')) && hasText('Continue')) || (kindOfClass('RCTTextView') && an object with accessibilityLabel "Continue"))))))", "Recovery Suggestion": "Check if the element exists in the UI hierarchy printed below. If it exists, adjust the matcher so that it accurately matches element." }enter image description here

await element(by.text('Continue').and(by.type('_UIAlertControllerActionView'))).tap(); Error: Cannot find UI element.


Solution

  • That’s not an alert you can interact with. That alert is rendered by a different process than your app, and Detox cannot interact with it. Instead, you should mock the API that shows this.