Goal: I am trying to finish the first step in the authentication process for a website (api). To do so, the last step is to obtain a code that is in the url (address bar) once it has redirected (this is my guess).
In short, I have figured out how to input the username / password. From there it loads a new page, and then that page loads another page (my best guess is that it checks to ensure all the information is correct) which holds a code in the url.
var puppeteer = require("puppeteer");
let clientInfo = require("./Client_Information.json");
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(
`https://url-goes-here.com?response_type=code&client_id=${clientInfo.client_id}`
);
await page.screenshot({ path: "./ScreenShots/ScreenShot.png" });
// Enter username GOOD
await page.click("#user_id");
await page.keyboard.type(clientInfo.user_name);
await page.screenshot({ path: "./ScreenShots/ScreenShot1.png" });
console.log("Username has been inserted");
// Accepting Username GOOD
await page.click(".andes-button--large");
await page.screenshot({ path: "./ScreenShots/ScreenShot2.png" });
await page.keyboard.press("Accept"); //Enter Key
await page.screenshot({ path: "./ScreenShots/ScreenShot3.png" });
//Delay 1.5 Seconds
await page.waitForTimeout(1000);
// Enter Password GOOD
await page.click("#password");
await page.keyboard.type(clientInfo.password);
await page.screenshot({ path: "./ScreenShots/ScreenShot4.png" });
console.log("Password has been inserted");
// Accepting Password GOOD
await page.click("#action-complete");
await page.screenshot({ path: "./ScreenShots/ScreenShot5.png" });
await page.keyboard.press("Accept"); //Enter Key
await page.screenshot({ path: "./ScreenShots/ScreenShot6.png" });
//Delay 4 Seconds
await page.waitForNavigation();
await page.waitForTimeout(1000);
//URL Fetch GOOD
const url1 = await page.url();
console.log("Page URL : " + url1);
//Store URL
clientInfo.Step1_Url = url1;
//NOTE New Section
await page.waitForTimeout(10000);
const url2 = await page.url();
console.log("Page URL : " + url2);
await browser.close();
})();
In the //NOTE New Section area is where I am waiting to get the actual resolve redirect, though instead I get chrome-error://chromewebdata/ vs the expected url+code. Thoughts?
question from:
https://stackoverflow.com/questions/65853721/how-do-i-return-the-value-of-a-redirected-link-in-puppeteer 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…