gpt4 book ai didi

java - 使用 WebDriver/HtmlUnit 获取所有 HTTP 请求

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:06:15 28 4
gpt4 key购买 nike

我需要通过 WebDriver 验证测试请求。不幸的是,由于没有 native 支持,因此没有简单的方法可以做到这一点。似乎我应该能够使用 HtmlUnit 来获取请求,但我只能得到响应。有没有办法用 HtmlUnit 来做到这一点,或者我是否需要设置其他东西,比如 Browsermob 代理?我正在使用 Java 来执行此操作。

谢谢!

最佳答案

我在下面提供了一个使用 HtmlUnit 的示例:

final WebClient webClient = new WebClient(BrowserVersion.CHROME);
final HtmlPage loginPage = webClient.getPage("http://www.stackoverflow.com");
WebResponse response = loginPage.getWebResponse(); // the response loaded to create this page
WebRequest request = response.getWebRequest(); // the request used to load this page

关于java - 使用 WebDriver/HtmlUnit 获取所有 HTTP 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21119852/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com