问题描述
我正在使用 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(和其他错误)
- 检查分析代码是否正常工作(检查它是否发送正确的请求)
根据项目,我使用带有 Netexport 的 Firebug 或 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:
- Java 中的 Selenium CaptureNetworkTraffic 示例
- HOWTO:收集 WebDriver HTTP请求和响应标头
- 使用 Selenium 2 自动捕获 Web 时序一个>
这篇关于如何在 webdriver 中捕获页面发出的所有请求?Browsermob有什么替代品吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!