[英]How to Navigate to 2nd Url (angular7) after success login in 1st Url
Can some one help me out.... how to navigate to angular7 page from the non-angular page by changing the url. 有人可以帮帮我吗...。如何通过更改URL从非角度页面导航到angular7页面。
please find my code snippet below: 请在下面找到我的代码段:
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();
Try to set page.setDefaultTimeout
"globally", after the const page = await browser.newPage();
在
const page = await browser.newPage();
之后,尝试“全局”设置page.setDefaultTimeout
const page = await browser.newPage();
command. 命令。 Like this:
像这样:
const page = await browser.newPage();
// add this line:
await page.setDefaultTimeout(5*60*1000); // 5 minutes in miliseconds
// rest of the code...
If your page takes more than 5 minutes, increase the timeout. 如果您的页面耗时超过5分钟,请增加超时时间。
Also in your code there is "networkIdleTimeout". 同样在您的代码中还有“ networkIdleTimeout”。 This has no effect to puppeteer, since it's not recognized.
由于未识别,这对操纵p没有影响。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.