简体   繁体   English

成功登录第一个网址后如何导航到第二个网址(angular7)

[英]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.

相关问题 如何在第二次之后停止第一次 function? - How to stop doing 1st function after 2nd? 当第二个中的第一个可观测值需要时,如何在angular2中链接两个可观测的对象 - How to chain two observables in angular2, when value of 1st observable need in 2nd one 如何在第一个异步方法完成后运行第二个异步方法 - How to make 2nd async method run after 1st async method has finished 如何搜索表的第二列而不是第一列 - How to search 2nd column of table instead of 1st column 如何根据从第一个下拉菜单自动更改的第二个下拉菜单更改第二个文本框的值? - How to change the 2nd textbox value based on the 2nd dropdown that is automatically changed from 1st dropdown? 从第一个填充第二个列表框 - populate 2nd listbox from 1st 计算完成位置 1st、2nd=、2nd= 等 - Calculate finishing positions 1st, 2nd=, 2nd=, etc 将文本拆分为第一个“;”然后再按第二个“;”拆分 - split text by 1st “;” and then again by 2nd “;” 我这里有 2 个表格,在提交验证第一个表格后,我如何移动到第二个表格进行验证? - I have 2 forms here,after submitting validatting the 1st one, how can I move to the 2nd to validate? 第一个单词第一个字符第二个单词第二个字符直到数组结尾 - 1st word 1st character 2nd word 2nd character and on till the end of array
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM