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

Waiting for one of the selectors or alert windows #53

Closed
AngangGuo opened this issue Oct 22, 2020 · 2 comments
Closed

Waiting for one of the selectors or alert windows #53

AngangGuo opened this issue Oct 22, 2020 · 2 comments

Comments

@AngangGuo
Copy link

I want to use this library to automate my daily tasks, like giving a job id, go to a page find all the pallets of this job and process these pallets one by one. Or giving an asset id, I verify if all the processing data are valid for this asset, etc.

When I click a button, it may show out different content, or alert messages according to the data.
What's the proper way in playwright-go to process these situation?

What's the correct way to do this in playwright-go?

    await page.goto(loadLink)

    // if load id is valid, this PALLET DETAILS table will show out
    const hdTable = "#ctl00_ctl00_LoadPallet"
    // if load id is invalid, it will show warning window with this close button
    const closeButton = "#ctl00_ctl00_LoadGridClose"
    await Promise.race([
        page.click(closeButton).then(() => false),
        page.waitForSelector(hdTable).then(() => true)
    ]).then(value => {
        if (!value) {
            console.log("wrong load id: ", loadID)
            return
        }
    })

Thanks

@mxschmitt
Copy link
Member

mxschmitt commented Dec 29, 2020

Hi sorry for the late response, maybe using time.After in combination with a switch to have similar Promise.race behaviour could work.

For automating daily tasks I would probably use JavaScript / Node.js since in Go its kinda abstract.

@AngangGuo
Copy link
Author

Thanks for the advise.

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

No branches or pull requests

2 participants