Visual Studio Web性能和负载测试中的REGEX提取规则 [英] REGEX Extraction rule in Visual Studio Web Performance and Load Testing

查看:75
本文介绍了Visual Studio Web性能和负载测试中的REGEX提取规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个REGEX我需要用来从我的一个测试中通过Visual Studio Web性能和负载测试从响应中提取特定ID 。我遇到的问题是,当我使用不同的工具在线测试时,REGEX似乎工作得很好,
但是在提取规则中使用时没有给我预期的结果。

I have a REGEX I need to use to extract a particular ID from a response in one of my tests with Visual Studio Web Performance and Load Testing. The problem I am having is that the REGEX seems to work fine when I test it online with different tools, but is not giving me the expected result when used within an extraction rule.

这是场景。我从调用中得到了大量的HTML结果。以下是两个示例:

Here's the scenario. I get large resultat of HTML from my calls. Here are two examples:

示例1:

-<div id="ht_5_0" a="29" o="2000002" class="ocq">
-<span class="a">
<a o="108" class="oan wk" tabindex="-1" target="_blank" href="10-8-ht_5_0.ice#">Some Static String</a>
</span>
</div>

示例2:

-<div o="2000002" id="in_5_0" a="29" class="ocq">
-<span class="a">
<a o="108" class="oan wk" tabindex="-1" target="_blank" href="10-2-in_5_0.ice#">Some Static String</a>
</span>
</div>

我需要从每条消息的href中提取以下ID: 

I need to extract the following id from the href of each message: 

示例1:ht_5

示例2:in_5

我提出了以下正则表达式,似乎可行在线罚款:

I have come up with the following regex which seems to work fine online:

href =" ..- .-(。*)_ 0 \ .ice#">一些静态字符串

href="..-.-(.*)_0\.ice#">Some Static String

但是当我将它应用于我的提取规则时它不起作用。是否有关于在Visual Studio Web性能和负载测试提取规则中使用哪种REGEX样式的指南?

But it doesn't work when I apply it to my extraction rule. Are there guidelines as to what style of REGEX to use in a Visual Studio Web Performance and Load Testing extraction rule?

非常感谢,




推荐答案

嗨Simon50,

Hi Simon50,

您是如何在Web测试请求中使用提取规则的?

How did you use the extraction rule in your web test request?

您是否像这种情况一样使用Extract Regular Expression?

Do you use the Extract Regular Expression like this case?

https://social.msdn.microsoft.com/Forums/en-US/bad73d3c-4814-40d0-b150-d7a7f3119950/regular-expression-in-web-performance-test-extraction-rule? forum = vstswebtest

AdrianHHH提供了一个使用插件提取和格式化所需数据的建议,然后这个插件本身应该从$ b访问响应主体$ b e.Response.BodyString 。也许这对你来说是一条更好的道路。

AdrianHHH provide a suggestion which use the plug-in to extracts and formats the required data, and then this plugin itself should access the response body from e.Response.BodyString. Maybe it is a better path for you.

有关更多详细信息,请参阅:

For more detailed information, see:

http://stackoverflow.com/questions/24117990/regex-in-vsts-web-test

最诚挚的问候,

杰克


这篇关于Visual Studio Web性能和负载测试中的REGEX提取规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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