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

查看:432
本文介绍了使用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天全站免登陆