本文介绍了读取浏览器在 C# webdriver 中导航网页时发出的请求和响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想读取浏览器在页面上导航时发出的所有请求和响应.

I wants to read all the requests and responses made and get by the browser on navigating on a page.

例如:如果我导航到 http://www.yahoo.com 然后我们观察到浏览器正在发出大量 GET 和 post 请求.用于图片加载、内容加载和展示广告(Advertisement).

For ex:If I navigate to http://www.yahoo.com thenwe observe that browser is making a lots of GET and post requests.For the purpose of image loading, content loading and to display the Ads (Advertisement).

我正在使用 selenium 网络驱动程序和 C#.

I am using selenium web driver and C#.

你能帮助我如何获得所有请求(获取/发布)和响应.

Can you please help me how can I get all the requests (get/post) and responses.

谢谢,拉梅什·贾贾里亚

Thanks,Ramesh Jhajharia

推荐答案

实现此目的的最佳方法是使用某种可编写脚本的代理.一个这样的代理是 BrowserMob 代理,甚至还有一个 .NET 包装器.这将允许您收集 WebDriver 范围之外的信息,例如您请求的原始 HTTP 请求.

The best way to accomplish this is to use some sort of scriptable proxy. One such proxy is the BrowserMob proxy, and there's even a .NET wrapper for it. This would allow you to gather information that is outside the scope of WebDriver, such as the raw HTTP requests that you are asking for.

这篇关于读取浏览器在 C# webdriver 中导航网页时发出的请求和响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 04:30