detox-expo-helpers icon indicating copy to clipboard operation
detox-expo-helpers copied to clipboard

Cant find element by testID in IOS

Open Kristijan-Karanfiloski opened this issue 1 year ago • 0 comments

I have a very complex app that I'm starting to test at the moment I'm testing the dev code the app is made with EXPO and at lunching the app I have the console debugger I figured out how to close that but now I'm using test id on an input and my test is failing I need some help

This is the original text input

THIS IS MY TEST

import { device, element, by, waitFor } from 'detox';

describe('player app Activation screen', () => { beforeAll(async () => { //new instance makes to close the app and start it again

await device.launchApp({ newInstance: true });

//{
//       newInstance: true
//     }

await device.openURL({
  url: `exp+next11-reaxt-native-v2://expo-development-client/?url=${encodeURIComponent(
    `http://localhost:8081`
  )}`
});

}); beforeEach(async () => { // await device.reloadReactNative(); });

it('set up for the development console ', async () => { await waitFor(element(by.text('Got It'))) .toBeVisible() .withTimeout(3000);

await element(by.text('Got It')).tap();
await element(by.text('Connected to:')).swipe('down');

});

it('should have a title Welcome', async () => { await expect(element(by.text('Welcome!'))).toBeVisible(); });

const typedText = '45689';

it('should have an input activation code and accept input', async () => { await element(by.id('emailField')).typeText('[email protected]'); }); });

THIS IS THE ERROR IM GETTING IN MY CONSOLE

e2e/playerAppLoginScreen.test.js (37.985 s) player app Activation screen ✓ set up for the development console (14812 ms) ✓ should have a title Welcome (334 ms) ✕ should have an input activation code and accept input (187 ms)

● player app Activation screen › should have an input activation code and accept input

Test Failed: No elements found for “MATCHER(id == “emailField”)”

HINT: To print view hierarchy on failed actions/matches, use log-level verbose or higher.

  56 |     //   .toBeVisible()
  57 |     //   .withTimeout(2000);
> 58 |     await element(by.id('emailField')).typeText('[email protected]');
     |                                        ^
  59 |
  60 |     // const input = element(by.id('input'));
  61 |     // await input.tap();

  at Object.typeText (e2e/playerAppLoginScreen.test.js:58:40)
  at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
  at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)
  at node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:7
  at Object.<anonymous> (node_modules/@babel/runtime/helpers/asyncToGenerator.js:19:12)

Test Suites: 1 failed, 1 total Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: 38.583 s, estimated 40 s Ran all test suites. 15:58:26.238 detox[24733] E Command failed with exit code = 1: jest --config e2e/jest.config.js

Kristijan-Karanfiloski avatar Jan 03 '24 15:01 Kristijan-Karanfiloski