1

I'm using webdriverIO with typescript and jest to automate react application. I have a simple test to check how long it takes for a particular element to display on the screen. There's a process which runs on clicking a button and once the process is completed, a popup is displayed on the screen.

I'm printing time before I wait for the element and then printing it after. Below is the code:

 $("//button[@testid='btn-submit']").click();
    const time1 = Date.now();
    console.log("Time started --- " + time1);
    $(".messagedialog").waitForExist(600000);
    const time2 = Date.now();
    console.log("Time Ended --- " + time2);
    $("//span[text()='View Result']").click();

When it runs, it prints the line "Time Ended --" right after "Time Started -- ", even though the application is still waiting for the message dialog. I'm running webdriverIO in the sync mode using @wdio/sync.

Why the "Time Ended" line is getting printed even though previous statement ".waitForExist()" has not returned true yet?

  • It's working correctly for me, make sure that .messagedialog is not present in the DOM because waitforexit check only for the presence and not visibility. – PDHide Mar 20 at 8:45
  • 1
    Thanks! That was it.. there was another dialog on the screen with the same class name, causing this issue. – Dougg Mar 20 at 21:16
  • please accept the answer by clicking the tick sign near to the answer – PDHide Mar 22 at 21:38
1

WaitForExit() checks only for the presence of and not the visibility . You could use $(selector).waitForDisplayed instead . And also ensure there is no other element with the same selector

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.