使用Web浏览器的现有实例从C#代码中访问响应数据包 [英] Accessing Response Packet from within C# code, using an existing instance of Web Browser

查看:155
本文介绍了使用Web浏览器的现有实例从C#代码中访问响应数据包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Visual Studio 2010中编写C#编码的UI测试.为了增强测试,我需要访问从服务器返回的所有响应.例如,我正在测试添加新成员"用例,如果用户尝试添加新成员失败,并且UI既未显示成功消息也未显示失败消息,我希望能够从http获取更多详细信息响应并向测试人员显示适当的响应.

我的代码首先打开
的实例

I am writing C# Coded UI Tests in Visual Studio 2010. To enhance the testing, I need to access all the responses coming back from the server. For instance, I am testing the Add New Member use case, if user’s attempt to add a new member fails, and the UI doesn''t show neither the success or failure massage, I want to be able to get more detail from the http response and show the appropriate respond to the tester.

My code first open an instance of

SHDocVw.ShellWindows allBrowsers = new SHDocVw.ShellWindows();

                if (allBrowsers.Count > 1)
                {

                    MessageBox.Show("Number active browsers = " + allBrowsers.Count + "." + " Please close all windows and try again...");

                    throw new Exception("Multiple IE Instances not allow ");

                }

                p = Process.Start("iexplore.exe", "http://bing/");

                BrowserWindow win = new BrowserWindow();

                current.SearchProperties[BrowserWindow.PropertyNames.Name] = "Bing";

               if (p == null) throw new Exception("Could not launch IE");



现在,我需要以某种方式捕获服务器发送回从win对象实例发出的请求的所有响应?

我不确定是否可以使用HttpContext之类的方法.

谢谢

Ali



Now, I need to somehow capture all the responses that server sends back to requests going out from the instance of win object?

I am not sure if there is any way to do with HttpContext or such.

Thanks

Ali

推荐答案

在运行外部进程时,您将不会使用Test代码来获得它.您需要使用提琴手 [
You''re not going to get that using your Test code when you''re running external processes. You''ll need to use a tool like Fiddler[^] to grab all the HTTP traffic.


这篇关于使用Web浏览器的现有实例从C#代码中访问响应数据包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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