简体   繁体   English

WebAii 测试 web 页面生成非 html 内容(CSV、JSON、XML ......)

[英]WebAii Test web page that produces non-html content (CSV, JSON, XML…)

I use WebAii to test an ASP.Net application.我使用 WebAii 来测试一个 ASP.Net 应用程序。 This application has an "Export to CSV" feature, and I would like to test that it works correctly with WebAii.此应用程序具有“导出到 CSV”功能,我想测试它是否可以与 WebAii 一起正常工作。 Is there a way to access the exact source that was generated for a page?有没有办法访问为页面生成的确切源?

I tried using ActiveBrowser.ViewSourceString, but it appears to work only for HTML.我尝试使用 ActiveBrowser.ViewSourceString,但它似乎只适用于 HTML。 (it contains the HTML of the page that called the "Export to CSV" instead of the CSV content) (它包含调用“导出到 CSV”的页面的 HTML 而不是 CSV 内容)

It may seem strange to use WebAii to test plain text content, when I could bypass WebAii and the browser and use HttpRequest to directly call the page.使用 WebAii 测试纯文本内容可能看起来很奇怪,当我可以绕过 WebAii 和浏览器并使用 HttpRequest 直接调用页面时。 The reason why I need to do it this way is that the Export to CSV gets its parameters (a series of search filters) on the query string, and I need to make sure the calling code (an ASP.Net web page) is correctly passing the right parameters.我需要这样做的原因是 Export to CSV 在查询字符串上获取其参数(一系列搜索过滤器),并且我需要确保调用代码(ASP.Net web 页面)正确传递正确的参数。

I work in Telerik's technical support department for WebAii.我在 Telerik 的 WebAii 技术支持部门工作。 I'll try to assist.我会尽力提供帮助。 I need to know what happens when you click this "Export to CSV" button/link.我需要知道当您单击此“导出为 CSV”按钮/链接时会发生什么。 Normally such a button causes the webserver to create a file and send it to the browser for downloading.通常这样的按钮会导致网络服务器创建一个文件并将其发送到浏览器进行下载。 You then save it as a file on your local machine.然后将其保存为本地计算机上的文件。 Is this what is happening or is the browser simply displaying the CSV content in its window?这是正在发生的事情,还是浏览器只是在其 window 中显示 CSV 内容?

ActiveBrowser.ViewSourceString is the right approach for getting at the HTML loaded in the browser window. ActiveBrowser.ViewSourceString 是获取浏览器 window 中加载的 HTML 的正确方法。 It is possible that HTML contained in the framework is out of sync with what's actually in the browser.框架中包含的 HTML 可能与浏览器中的实际内容不同步。 We cache the DOM for performance reasons.我们出于性能原因缓存 DOM。 You can use:您可以使用:

ActiveBrowser.RefreshDomTree(); ActiveBrowser.RefreshDomTree();

This forces the framework to resync it's copy of the DOM with what's actually contained in the browser.这迫使框架将其 DOM 副本与浏览器中实际包含的内容重新同步。 See if ActiveBrowser.ViewSourceString is now different after clicking on your "Export to CSV" button/link.单击“导出到 CSV”按钮/链接后,查看 ActiveBrowser.ViewSourceString 现在是否有所不同。

Feel free to post questions like this on our Telerik Testing Framework forum.随时在我们的 Telerik 测试框架论坛上发布此类问题。 http://www.telerik.com/automated-testing-tools/community/forums/webui-test-studio-developer-edition/webaii-automation-framework.aspx . http://www.telerik.com/automated-testing-tools/community/forums/webui-test-studio-developer-edition/webaii-automation-framework.aspx This is where I hang out daily.这是我每天闲逛的地方。

Cody科迪

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM