0

I am trying to write tests for my application using Detox. but while navigating screen from Login screen my tests get failed due to matcher not found. I have added testID properly in render function still getting an error. here is my tests code:

it('should login successfully', async () => {
await device.reloadReactNative();

await element(by.id('textInput_username_login')).typeText('test');
await element(by.id('textInput_password_login')).typeText('123456');
await element(by.text('Log In')).tap();
await expect(element(by.id('otp'))).toBeVisible();
});

getting below error:

Test Failed: No elements found for “MATCHER(identifier == “ otp” && NOT DESCENDANT(class ⊇ “RCTTextView” && identifier == “ otp”))”

Thanks in advance.

user2586519
  • 250
  • 1
  • 6
  • 18

2 Answers2

0

The testID must not be getting added properly. If you're running on iOS you can add the --loglevel verbose parameter and look through the printed hierarchy for the element you expect to see and check if the id is on it or if it's even on the screen.

Tardis
  • 71
  • 4
0

Another option is to use Flutter's layout inspector to find the element and verify it has a test id that matches "otp": https://fbflipper.com. You can download it as a desktop app, though Mac's will complain because it isn't from the App Store, just as a heads up.