Search code examples
iosautomated-testsdetox

Testing timeout-related tests, such as Popups/Tooltips etc with Detox


I've beed using detox for a while, but after upgrade to 17.5.+ I have started facing an issue with Popups testing. I haven't find useful info on a stack overflow and on detox issues.

Problem here is the following: I have a test to check if correct popup is shown. It looks like:

it('expect to see "Answer correct" popup', async () => {
  await openQuestionnaire('theory_questionnaire_learn_button');

  await scroll('questionnaire_scroll_view', 150);

  await element(by.id('select_1_button')).tap();

  await element(by.id('questionnaire_answer_button')).tap();

  // @ts-ignore
  await expect(element(by.id('questionnaire_simple_popup'))).toBeVisible();
  // @ts-ignore
  await expect(element(by.id('questionnaire_simple_popup'))).toHaveLabel('correct');

  await delay(500);

  // @ts-ignore
  await expect(element(by.id('questionnaire_simple_popup'))).toNotExist();
});

Background for this: after questionnaire_answer_button is tapped, popup appears. It is visible for 500ms and then it disappears. For this 500ms I'm using setTimeout({ () => dismiss() }, 500).

Popup is visible on an emulator, but my test fails with Test Failed: No elements found for “MATCHER(identifier: == “questionnaire_simple_popup”)”

Checking hierarchy I haven't find this element there. Maybe someone else have already faced this and know a solution?


Solution

  • Ok, what have I found out after several tries. It start working after increasing timeout from 500ms to 3000ms. 2500 was still failing, 2750 haven't tried. Regarding matchers. by.id and by.text works as well.

    So the reason probably was a timeout duration.