-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
docs: add new doc for multi-page scenarios #2737
Conversation
docs/multi-pages.md
Outdated
const pageTwo = await context.newPage(); | ||
|
||
// Get pages of a brower context | ||
const allPages = await context.pages(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to await pages(), it is sync.
docs/multi-pages.md
Outdated
console.log(await newPage.title()); | ||
|
||
// Get all new pages (including popups) in the context | ||
context.on('page', page => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async page => ...
for it to compile :)- same thing about domcontentloaded
docs/multi-pages.md
Outdated
await popup.title(); | ||
|
||
// Get all popups when they open | ||
page.on('popup', popup => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here:
- async
- waitForLoadState
context.waitForEvent('page'), | ||
page.evaluate(() => window.open('https://google.com', '_blank')) | ||
]) | ||
console.log(await newPage.title()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need at least domcontentloaded before accessing title, but preferably load for everything else.
await newPage.waitForLoadState('domcontentloaded');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Updated to use newPage.waitForLoadState()
since that covers more scenarios for the audience of a guide like this.
page.waitForEvent('popup'), | ||
page.click('#open') | ||
]); | ||
await popup.title(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use popup.waitForLoadState()
Closes #2602