使用vb从编码的Webtest中的响应正文中提取文本 [英] Extract Text from Response Body in Coded Webtest using vb
问题描述
我在Visual Studio中有一个Web性能脚本.通过单击生成代码"按钮,我已将其转换为VB中的编码Webtest".
I have a Web performance Script in Visual Studio. I have turned this into Coded Webtest in VB by clicking on the Generate Code button.
在我的网络测试中,有5个功能.除1号以外,其他均用于SQL过程.
In my web test there are a 5 functions. Apart from the 1st the others are for SQL Procedures.
在一些事情中,我需要一个执行特定操作的Web请求.基于该操作,在响应正文中-它生成一个唯一ID.
Among a few things, I need a web request that does a certain action. Based on that action, In the response body - it generates a Unique Id.
我需要此ID以使其可在所有功能中访问.
I need this Id to make it accessible across all the functions.
响应主体是这样的:
0x00000000 7B 22 69 64 22 3A 36 35 33 30 36 36 33 7D {"id":2133221}
现在我想知道,我该怎么做.我只需要2133221
.
Now I wanted to know, how do I do it. I just need 2133221
.
我尝试过 使用上下文参数名称并将其附加到.to字符串...这是行不通的.我尝试通过查看网络并尝试一些选择来进行操作.我现在迷路了.谁能帮忙.
I tried using the Context Parameter name and appending it to a .to string...it did not work. I tried doing by looking over the net and trying out a few options. I'm lost now. Can anyone help.
推荐答案
最简单的解决方案是以下解决方案.
The simplest solution is the below one.
str = "0x00000000 7B 22 69 64 22 3A 36 35 33 30 36 36 33 7D {""id"":2133221}"
arr = Split(str, ":")
strID = Left(arr(1), len(arr(1)) - 1)
msgbox strId
但是,如果您仍然需要更强大的功能,请尝试regex
However, If you still need a more robust one, try regex
这篇关于使用vb从编码的Webtest中的响应正文中提取文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!