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

Extend the waitFor api to wait for elements #531

Closed
zabil opened this issue May 8, 2019 · 5 comments
Closed

Extend the waitFor api to wait for elements #531

zabil opened this issue May 8, 2019 · 5 comments
Assignees

Comments

@zabil
Copy link
Member

zabil commented May 8, 2019

Current behaviour

Taiko's page actions like click, write etc waits for the page navigation to complete. This may slow down tests.

Also in some cases tests need to wait for an action to complete before proceeding.

Solution

Extend the waitFor API to wait for specific elements to appear on the page so that the user can gracefully handle tests.

For example speed up tests without loading the entire page.

await click("Checkout", {waitForNavigation: false})
await waitFor("1 item in cart")
await click("Proceed to Pay")

or for a process that takes time

await click("Place order")
await waitFor("Order Created", intervalSecs(20)) // where creating an order takes 20 seconds
await click("Print")
@dmolin
Copy link

dmolin commented May 10, 2019

+1

@supraja-kr
Copy link

We are facing the same challenge in our team too.

@Debashis9012
Copy link
Contributor

Debashis9012 commented Jun 12, 2019

I have validated the above feature request Kindly find the below observation:

I have used the waitFor("element",5000) and waitFor("element") to load the element properly so that we can perform the actions(like click/enter text) gracefully.

It seems its only checking for the text and once it finds out the text on the screen then the control is moving to next line to perform the action on the webelement.
But in real the element is taking more time to gets loaded(or taking more time to load in a stable condition) on the screen which leads to fail perform correct action. Until the element loads properly we cant perform any correct action on it.
Kindly find the below script for reference:

const { openBrowser, goto, text, click, below, link, toRightOf, waitFor } = require('taiko');

(async () => {
    try {
        await openBrowser({headless:false});
        await goto("www.zomato.com/bangalore");
        await click(text("Pocket-Friendly Delivery"));
        //await waitFor("Order Food Online",5000)
        await waitFor("Order Food Online")
        await click("Order Food Online");
    } catch (e) {
        console.error(e);
    } finally {
    //    closeBrowser();
    }
})();

Commit: 082018c0c4081144b2dc19b0f375d0a256d94b3c

@Apoorva-GA
Copy link
Contributor

The problem is that, in the above script we should wait for the new element that is shifting the layout to exist, which is same as issue.

Also the fix to waitFor to element selected using a selector is fixed as part of a84409d.

@Debashis9012
Copy link
Contributor

This issue has been verified and found fixed with the commit version a84409d

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

7 participants