taiko icon indicating copy to clipboard operation
taiko copied to clipboard

waitfor working intermittenly

Open lane711 opened this issue 1 year ago • 3 comments

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());

lane711 avatar May 03 '24 16:05 lane711

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

DCoomer avatar May 03 '24 17:05 DCoomer

different issues happen for example:

  1. Query function should return a DOM Node or DOM NodeList
  2. Element 'Add New' not found within 10000 ms

On Fri, May 3, 2024 at 10:57 AM DCoomer @.***> wrote:

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

— Reply to this email directly, view it on GitHub https://github.com/getgauge/taiko/issues/2724#issuecomment-2093501535, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBGCC4MXOQBZVQRZGR664LZAPFYHAVCNFSM6AAAAABHFYXJDKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJTGUYDCNJTGU . You are receiving this because you authored the thread.Message ID: @.***>

lane711 avatar May 03 '24 19:05 lane711

  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.

NivedhaSenthil avatar May 06 '24 07:05 NivedhaSenthil