有人能帮帮我吗……如何通过更改url从非角度页面导航到angular7页面。
请在下面找到我的代码片段:
const puppeteer = require('puppeteer');
async function getPic() {
const browser = await puppeteer.launch({
headless : false,
args : ['--window-size=1920,1080']
});
const page = await browser.newPage();
//1st url is non angular page
await page.goto('https://LT.html', {
waitUntil : 'networkidle2',
timeout : 3000000
});
await page.waitForSelector('#login-form #userInput');
await page.click('#login-form #userInput');
await page.type('#login-form #userInput', 'rkatkam');
await page.waitForSelector('#login-form #passwordInput');
await page.click('#login-form #passwordInput');
await page.type('#login-form #passwordInput', 'cisco123');
await page.waitForSelector('#login-wrapper > #login #login-button');
await Promise.all([
page.waitForNavigation(),
page.click('#login-wrapper > #login #login-button')
]);
//now after getting the authentication success, i have to navigate to 2nd url (my actual application url
// this is angular7 page. this page takes time to load by that time my script is timing out
//timeout 30000ms exceeded
await page.goto('https://myactualapplication/', { //2nd url
// networkIdleTimeout: 5000,
waitUntil: 'networkidle2'
});
}
getPic();发布于 2019-09-13 21:03:56
在const page = await browser.newPage();命令之后,尝试将page.setDefaultTimeout设置为“全局”。如下所示:
const page = await browser.newPage();
// add this line:
await page.setDefaultTimeout(5*60*1000); // 5 minutes in miliseconds
// rest of the code...如果页面耗时超过5分钟,请增加超时时间。
在你的代码中也有"networkIdleTimeout“。这对木偶操纵者没有影响,因为它不被识别。
https://stackoverflow.com/questions/57921572
复制相似问题