Skip to content

Commit

Permalink
Async touchscreen example
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed May 20, 2024
1 parent dba8f09 commit 99686df
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions examples/touchscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ export const options = {
export default async function () {
const page = await browser.newPage();

await page.goto('https://test.k6.io/', { waitUntil: 'networkidle' });
await page.goto("https://test.k6.io/", { waitUntil: "networkidle" });

// Obtain ElementHandle for news link and navigate to it
// by tapping in the 'a' element's bounding box
const newsLinkBox = page.$('a[href="/news.php"]').boundingBox();
await page.touchscreen.tap(newsLinkBox.x + newsLinkBox.width / 2, newsLinkBox.y);
const newsLinkBox = await page.$('a[href="/news.php"]').boundingBox();

// Wait until the navigation is done before closing the page.
// Otherwise, there will be a race condition between the page closing
// and the navigation.
await page.waitForNavigation({ waitUntil: 'networkidle' });
await Promise.all([
page.waitForNavigation(),
page.touchscreen.tap(newsLinkBox.x + newsLinkBox.width / 2, newsLinkBox.y),
]);

page.close();
}

0 comments on commit 99686df

Please sign in to comment.