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

Fix Async examples #1368

Merged
merged 4 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 7 additions & 20 deletions examples/elementstate.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,13 @@ export default async function() {
`);

// Check state
let el = await page.$('.visible');
const isVisible = await el.isVisible();

el = await page.$('.hidden');
const isHidden = await el.isHidden();

el = await page.$('.editable');
const isEditable = await el.isEditable();

el = await page.$('.enabled');
const isEnabled = await el.isEnabled();

el = await page.$('.disabled');
const isDisabled = await el.isDisabled();

el = await page.$('.checked');
const isChecked = await el.isChecked();

el = await page.$('.unchecked');
const isUnchecked = await el.isChecked() === false;
let isVisible = await page.$('.visible').then(e => e.isVisible());
let isHidden = await page.$('.hidden').then(e => e.isHidden());
let isEditable = await page.$('.editable').then(e => e.isEditable());
let isEnabled = await page.$('.enabled').then(e => e.isEnabled());
let isDisabled = await page.$('.disabled').then(e => e.isDisabled());
let isChecked = await page.$('.checked').then(e => e.isChecked());
let isUnchecked = !await page.$('.unchecked').then(e => e.isChecked());

check(page, {
'visible': isVisible,
Expand Down
2 changes: 1 addition & 1 deletion examples/mouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default async function () {

// Obtain ElementHandle for news link and navigate to it
// by clicking in the 'a' element's bounding box
const newsLinkBox = await page.$('a[href="/news.php"]').boundingBox();
const newsLinkBox = await page.$('a[href="/news.php"]').then(e => e.boundingBox());

await Promise.all([
page.waitForNavigation(),
Expand Down
4 changes: 2 additions & 2 deletions examples/querying.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export default async function() {
try {
await page.goto('https://test.k6.io/');

const titleWithCSS = await page.$('header h1.title').textContent();
const titleWithXPath = await page.$(`//header//h1[@class="title"]`).textContent();
const titleWithCSS = await page.$('header h1.title').then(e => e.textContent());
const titleWithXPath = await page.$(`//header//h1[@class="title"]`).then(e => e.textContent());

check(page, {
'Title with CSS selector': titleWithCSS == 'test.k6.io',
Expand Down
2 changes: 1 addition & 1 deletion examples/touchscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default async function () {

// Obtain ElementHandle for news link and navigate to it
// by tapping in the 'a' element's bounding box
const newsLinkBox = await page.$('a[href="/news.php"]').boundingBox();
const newsLinkBox = await page.$('a[href="/news.php"]').then((e) => e.boundingBox());

// Wait until the navigation is done before closing the page.
// Otherwise, there will be a race condition between the page closing
Expand Down
Loading