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

Async Click #439

Closed
Tracked by #428
inancgumus opened this issue Jul 7, 2022 · 0 comments · Fixed by #466
Closed
Tracked by #428

Async Click #439

inancgumus opened this issue Jul 7, 2022 · 0 comments · Fixed by #466
Assignees
Labels
async supports async (promises) feature A new feature
Milestone

Comments

@inancgumus
Copy link
Member

inancgumus commented Jul 7, 2022

Expected usage:

import { chromium } from 'k6/x/browser';

export default function() {
    const context = chromium.launch().newContext();
    const page = context.newPage();

    page.goto('https://test.k6.io/', { waitUntil: 'networkidle' });
    const elem = page.$('a[href="/my_messages.php"]');
    elem.click().then(() => {
        page.$('input[name="login"]').type('admin');
        page.$('input[name="password"]').type('123');
        return page.$('input[type="submit"]').click();
    }).then(() => {
        page.waitForLoadState('networkidle');
    }).finally(() => {
        page.close();
        browser.close();
    });
}

If k6 had supported async/await:

import { chromium } from 'k6/x/browser';

export default function() {
    const context = chromium.launch().newContext();
    const page = context.newPage();

    page.goto('https://test.k6.io/', { waitUntil: 'networkidle' });
    const elem = page.$('a[href="/my_messages.php"]');
    await elem.click();

    page.$('input[name="login"]').type('admin');
    page.$('input[name="password"]').type('123');
    await page.$('input[type="submit"]').click();

    page.waitForLoadState('networkidle');

    page.close();
    browser.close();
}
@inancgumus inancgumus added feature A new feature async supports async (promises) labels Jul 7, 2022
@inancgumus inancgumus changed the title Page.Click Async: Page.Click Jul 7, 2022
@inancgumus inancgumus added this to the v0.5.0 milestone Jul 7, 2022
@inancgumus inancgumus self-assigned this Jul 7, 2022
@inancgumus inancgumus changed the title Async: Page.Click Async: Click Jul 7, 2022
@inancgumus inancgumus mentioned this issue Jul 19, 2022
inancgumus added a commit that referenced this issue Feb 23, 2023
Related: #311 and #439
Updates: #100
Closes: #660
inancgumus added a commit that referenced this issue Feb 23, 2023
Related: #311 and #439
Updates: #100
Closes: #660
inancgumus added a commit that referenced this issue Feb 23, 2023
Related: #311 and #439
Updates: #100
Closes: #660
@inancgumus inancgumus changed the title Async: Click Async Click May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
async supports async (promises) feature A new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant