如何在webdriver中捕获页面发出的所有请求?Browsermob 有什么替代品吗? [英] How to capture all requests made by page in webdriver? Is there any alternative to Browsermob?
问题描述
我正在使用 Selenium2/WebDriver 来测试我的 Web 应用程序.所有测试均使用 Java 编写并使用 Maven 运行.
I am using Selenium2/WebDriver to test my web applications. All the tests are written in Java and run with Maven.
在使用 webdriver 打开页面时,我想捕获页面发出的所有请求(图像、js 和 css 文件等).我使用这些数据主要有两个原因
While opening a page with webdriver I'd like to capture all the requests made by page (images, js and css files, etc). I use this data mainly for two reasons
- 检查调用中的 404(和其他错误)
- 检查分析代码是否正常工作(检查它是否发送了正确的请求)
根据项目,我使用 Firebug 和 Netexport 或 Browsermob 代理.在这两种情况下,我都可以轻松获取 HAR (Html ARchive) 文件,对其进行解析并提取我想要的数据.
Depending on the project I use either Firebug with Netexport or Browsermob proxy. In both cases I can easily obtain a HAR (Html ARchive) file, parse it and extract the data I want.
问题来了:我对这两种解决方案都不满意.当页面包含加载时间过长的视频时,我在获取 HAR 文件时遇到了特别的问题.我正在寻找更稳定的东西.
Here's the problem: I am not happy with neither of these solutions. I have especially problems with getting HAR file when a page contains video that is being loaded too long. I am looking for something more stable.
所以,问题是:
Browsermob 有什么替代品吗?我知道 FiddlerCore,但它是一个 .NET 库,我的测试是用 Java 编写的.我也听说过 Ajax DynaTrace,我知道有一些方法可以将它与 Selenium 集成,但我找到的文档是针对 Selenium-RC 而不是 WebDriver.
Is there any alternative to Browsermob? I know about FiddlerCore but it's a .NET library and my tests are written in Java. I've also heard about Ajax DynaTrace and I know that there is some way to integrate it with Selenium but the documentation I found was for Selenium-RC not WebDriver.
有没有办法将 DynaTrace 与 WebDriver 集成或将 FiddlerCore 与 Java 结合使用?
Is there any way to integrate DynaTrace with WebDriver or use FiddlerCore with Java?
还有其他方法可以实现我提到的目标吗?我正在寻找一个可以从我的代码中轻松控制的代理.将数据导出到 HAR 将是一个很大的优势.
Is there any other way to achieve the goals I mentioned? I am looking for a proxy that I can easily control from my code. Exporting data to HAR would be a great plus.
推荐答案
我发现了一个 google 群组讨论 关于这个话题.这些链接看起来像是 Browsermob 的有前途的替代品:
I found a google groups discussion on the topic. These links look like promising alternative to Browsermob:
这篇关于如何在webdriver中捕获页面发出的所有请求?Browsermob 有什么替代品吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!