我正在使用adal-angular
我的应用程序,一旦它导航到本地主机,它就会重定向到另一个网站进行登录。我收到了(node:38052) UnhandledPromiseRejectionWarning: Error: Navigation to http://localhost:8080/ was canceled by another one
。
(async () => {
try {
const browser = await playwright.chromium.launch();
const context = await browser.newContext();
const core = await context.newPage("http://localhost:8080/");
await page.screenshot({ path: `example.png` });
await browser.close();
} catch (e) {
console.log(e);
}
})();
此流程是常规的 AD 单点登录行为,我需要等待重定向结束,然后插入用户和密码以获取令牌并调用我的 API。
我尝试使用goto
无济于事:
const playwright = require("playwright");
(async () => {
try {
const browser = await playwright.chromium.launch();
const context = await browser.newContext();
const core = await context.newPage("about:blank");
const page = await core.goto("http://localhost:8080/");
await page.screenshot({ path: `example.png` });
await browser.close();
} catch (e) {
console.log(e);
}
})();
这是一个傀儡师的例子
const puppeteer = require("puppeteer");
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto("http://localhost:8080", { waitUntil: "networkidle2" });
await page.screenshot({ path: "example.png" });
await browser.close();
})();
最后,您将获得包含以下内容的图像: