如何在 Jmeter 中获取响应数据(sid)?
How to get response data (sid) in Jmeter?
我的测试计划(无效):
+ WebSocket Sampler
- Regular Expression Extractor
我的正则表达式:
响应数据:
[Message 1]
0{"sid":"1BdTy3e4-jfrVM67AAAR","upgrades":[],"pingInterval":25000,"pingTimeout":60000}
如何获得'sid'?
正则表达式"sid":"(.+?)"
就可以了。
尝试使用 Match no(0 for Random) = 1
正则表达式测试请看这里https://regex101.com/r/yW4oR3/1
如果您添加一个 Debug Sampler after your request and look into the View Results Tree 侦听器,您将看到您的正则表达式 returns 只有一个匹配项:
根据 Regular Expression Extractor 文档:
Match No. Indicates which match to use. The regular expression may match multiple times.
Use a value of zero to indicate JMeter should choose a match at random.
A positive number N means to select the nth match.
Negative numbers are used in conjunction with the ForEach Controller - see below.
因此您的 匹配号: 设置不正确,您需要删除 3
或将其更改为 1
有关确定 JMeter 测试失败原因的详细信息,请参阅 How to Debug your Apache JMeter Script 指南
我的测试计划(无效):
+ WebSocket Sampler
- Regular Expression Extractor
我的正则表达式:
响应数据:
[Message 1]
0{"sid":"1BdTy3e4-jfrVM67AAAR","upgrades":[],"pingInterval":25000,"pingTimeout":60000}
如何获得'sid'?
正则表达式"sid":"(.+?)"
就可以了。
尝试使用 Match no(0 for Random) = 1
正则表达式测试请看这里https://regex101.com/r/yW4oR3/1
如果您添加一个 Debug Sampler after your request and look into the View Results Tree 侦听器,您将看到您的正则表达式 returns 只有一个匹配项:
根据 Regular Expression Extractor 文档:
Match No. Indicates which match to use. The regular expression may match multiple times.
Use a value of zero to indicate JMeter should choose a match at random.
A positive number N means to select the nth match.
Negative numbers are used in conjunction with the ForEach Controller - see below.
因此您的 匹配号: 设置不正确,您需要删除 3
或将其更改为 1
有关确定 JMeter 测试失败原因的详细信息,请参阅 How to Debug your Apache JMeter Script 指南