Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

waitfor working intermittenly #2724

Open
lane711 opened this issue May 3, 2024 · 3 comments
Open

waitfor working intermittenly #2724

lane711 opened this issue May 3, 2024 · 3 comments

Comments

@lane711
Copy link

lane711 commented May 3, 2024

I am trying to create e2e ui tests for a complex Angular-based app. Almost all user interactions have an API call, so there are delays with nearly every click event.

I'm usingwaitFor for many times. It seems to work 90% of the time but not 100%. The only way around this that I've found is to add explicit wait via await waitFor(3000); before and after many interactions which is obviously not a good solution.

I'm working on a large enterprise project and many other developers working with Taiko have had to implement similar workarounds.

Is there some technique we should be trying to eliminate the explicit waits?

Here are some lines of code that intermittently fail:

 await goto(url, { waitForEvents: ["loadEventFired"] });
 await waitFor(async () => await text(" Item Management ").exists());
 await waitFor("Item Management ").exists());

 const btnAdd = $(() => {
   return document.querySelector(`.identify__im_add-new-open-menu-gl-button`);
 });
 await waitFor(async () => await btnAdd.exists());
 await click(btnAdd);

   await waitFor(async () => await text("Kit Name").exists());
   await write(kitname, into(textBox(near("Kit Name"))));

   await waitFor(async () => await text(" 1 – 3 of 3 ").exists());

@DCoomer
Copy link
Contributor

DCoomer commented May 3, 2024

What happens when you don't use waitFor(element), is there just a long delay to the next step or does the step fail?

You can also use await click(element,{waitForNavigation: false}) for Taiko to skip it's build in waits. or use setConfig({waitForNavigation: false}) to globally turn it off

@lane711
Copy link
Author

lane711 commented May 3, 2024 via email

@NivedhaSenthil
Copy link
Member

  1. First issue seems to be happening when Taiko is not able to find an element thats no longer present, this case has to be fixed in Taiko.
  2. This looks like a genuine case where the element took time to appear, you can probably try increasing the timeout if the page load is slow. Ideally actions should wait for elements to exists implicitly, increasing the timeout could let Taiko handle the waiting.

Will be helpful if you can provide a sample or logs when you see the first issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants