mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat(frame): introduce Frame.goto and Frame.waitForNavigation (#3276)
This patch introduces API to manage frame navigations. As a drive-by, the `response.frame()` method is added as a shortcut for `response.request().frame()`. Fixes #2918.
This commit is contained in:
@@ -37,16 +37,19 @@ const utils = module.exports = {
|
||||
* @param {!Page} page
|
||||
* @param {string} frameId
|
||||
* @param {string} url
|
||||
* @return {!Puppeteer.Frame}
|
||||
*/
|
||||
attachFrame: async function(page, frameId, url) {
|
||||
await page.evaluate(attachFrame, frameId, url);
|
||||
const handle = await page.evaluateHandle(attachFrame, frameId, url);
|
||||
return await handle.asElement().contentFrame();
|
||||
|
||||
function attachFrame(frameId, url) {
|
||||
async function attachFrame(frameId, url) {
|
||||
const frame = document.createElement('iframe');
|
||||
frame.src = url;
|
||||
frame.id = frameId;
|
||||
document.body.appendChild(frame);
|
||||
return new Promise(x => frame.onload = x);
|
||||
await new Promise(x => frame.onload = x);
|
||||
return frame;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user