点击按钮后,如何在Playwright中捕获请求和响应



我有以下Playwright代码:

await page.goto(API_URL + "/login/");
await page.type('input[name="userName"]', username);
await page.type('input[name="password"]', password);
await page.click('button#submit');

发生的情况是,大约有三个重定向。最后一个重定向是指向一个包含凭据数据的伪地址(基本上是一个字符串(。我需要提取。我怎样才能做到这一点?

需要添加:

const response = await page.waitForRequest(url => url.url().includes('templateFrom3rdRedirect'));

其中CCD_ 1是URL中对于必要的";"跳跃";捕获对伪url的调用(稍后在response.url()中找到(。

最新更新