Java Playwright获取重定向的响应正文

omjgkv6w  于 2022-11-27  发布在  Java
关注(0)|答案(1)|浏览(638)

我使用https://github.com/microsoft/playwright-java
此代码:

final BrowserContext context = browser.newContext();
final Page page = context.newPage();
page.onResponse(response -> {

    response.body();
    
});

给出了异常:Response body is unavailable for redirect responses,当发生重新导向时。是否有方法可以取得回应主体而不管?

z31licg0

z31licg01#

试试这个也许对你有帮助

final BrowserContext context = browser.newContext();
final Page page = context.newPage();
page.onResponse(response -> {
page.request().get(response.url()).body();
});

相关问题