簡體   English   中英

成功登錄第一個網址后如何導航到第二個網址(angular7)

[英]How to Navigate to 2nd Url (angular7) after success login in 1st Url

有人可以幫幫我嗎...。如何通過更改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();

const page = await browser.newPage();之后,嘗試“全局”設置page.setDefaultTimeout const page = await browser.newPage(); 命令。 像這樣:

const page = await browser.newPage();

// add this line:
await page.setDefaultTimeout(5*60*1000); // 5 minutes in miliseconds

// rest of the code...

如果您的頁面耗時超過5分鍾,請增加超時時間。

同樣在您的代碼中還有“ networkIdleTimeout”。 由於未識別,這對操縱p沒有影響。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM