使用 Selenium 检查 HTTP 响应标头的最佳方法 [英] The best way to inspect HTTP response headers with Selenium

查看:31
本文介绍了使用 Selenium 检查 HTTP 响应标头的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 Selenium 检查 HTTP 响应标头的最佳方法.我查看了 Selenium 文档,没有看到任何直接的方法.非常感谢您的帮助.

I need the best way to inspect HTTP response headers with Selenium. I looked around the Selenium docs and didn't see any straightforward way to do it. Help is highly appreciated.

推荐答案

我已经在 StackOverflow 上多次回答过这个问题.搜索我以前的答案以挖掘它.您必须编写一些扩展 ProxyHandler 和 SeleniumServer 的自定义 Java 代码的关键.您还需要使用 AFTER 1.0 beta 2 之后的版本.

I've answered this question a couple times on StackOverflow. Search my previous answers to dig it up. The key that you have to write some custom Java code that extends ProxyHandler and SeleniumServer. You also need to use a release AFTER 1.0 beta 2.

对于那些问为什么你想这样做的人:有很多原因.在我的例子中,我们正在测试一个 AJAX 繁重的应用程序,当出现问题时,我们首先要调试的事情之一就是网络线路.这有助于我们查看 AJAX 调用是否发生,如果发生,响应是什么.我们实际上是在每次 Selenium 测试中自动收集这些信息并捕获它(连同屏幕截图).

As to the people who ask why you'd want to do this: there are a lot of reasons. In my case, we're testing an AJAX heavy app and when things go wrong, one of the first things we debug is the network wire. That helps us see if the AJAX call happened and, if so, what the response was. We're actually automated the collection of this info and capture it (along with a screenshot) with every Selenium test.

这篇关于使用 Selenium 检查 HTTP 响应标头的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆