Jmeter正则表达式提取器变量不为第二个变量调用生成会话

时间:2022-03-21 13:00:28

I am testing a login system which stores a session in a variable. The variable is dynamic; meaning, its value changes for every request. I followed this tutorial http://sjpknight.com/correlating-dynamic-values-in-jmeter/ for doing this.

我正在测试一个登录系统,它将一个会话存储在一个变量中。变量是动态的;意思是,它的值会随着每个请求而变化。我按照本教程http://sjpknight.com/correlating-dynamic-values-in-jmeter/执行此操作。

Now, the thing is, this session variable (${session_store}) auto generates only for the first time it is called in my http samplers (I call it thrice in my application). The second time I call it, the value it has is the default value I stored in it in the Regular Expression Extractor element. Meaning, the auto generated value in the first variable call is not received by the second variable call. Right now, I am having an error since the values of the two variable calls are not the same. Any suggestions on how to fix this?

现在,问题是,这个会话变量($ {session_store})仅在我的http采样器中第一次调用它时自动生成(我在我的应用程序中称它为三次)。我第二次调用它时,它具有的值是我在Regular Expression Extractor元素中存储的默认值。意思是,第二个变量调用不接收第一个变量调用中的自动生成值。现在,我遇到了一个错误,因为两个变量调用的值不一样。对于如何解决这个问题,有任何的建议吗?

1 个解决方案

#1


0  

Add View Results Tree listener to your Test Plan and inspect the response in all 3 cases. As far as I understand you expect the same or similar response as in the 1st case and most likely it is different. You can test your Regular Expressions agains live responses directly in the View Results Tree listener using RegExp Tester mode

将View Results Tree监听器添加到您的测试计划中,并检查所有3种情况下的响应。据我所知,你期望与第一种情况相同或类似的反应,而且很可能是不同的。您可以使用RegExp Tester模式直接在View Results Tree侦听器中测试您的正则表达式实时响应

Jmeter正则表达式提取器变量不为第二个变量调用生成会话


In general when it comes to Regular Expressions and HTML you can never tell whether your expression provide a match or not as it depends on multiple factors and even a slight change in the markup, i.e. value you're looking for starts coming in 2 lines, will ruin your test so I would recommend to go for CSS/JQuery Extractor or XPath Extractor instead

一般来说,当涉及正则表达式和HTML时,你永远无法判断你的表达式是否提供匹配,因为它取决于多个因素,甚至标记的微小变化,即你正在寻找的值开始有2行,会破坏你的测试,所以我建议改用CSS / JQuery Extractor或XPath Extractor

#1


0  

Add View Results Tree listener to your Test Plan and inspect the response in all 3 cases. As far as I understand you expect the same or similar response as in the 1st case and most likely it is different. You can test your Regular Expressions agains live responses directly in the View Results Tree listener using RegExp Tester mode

将View Results Tree监听器添加到您的测试计划中,并检查所有3种情况下的响应。据我所知,你期望与第一种情况相同或类似的反应,而且很可能是不同的。您可以使用RegExp Tester模式直接在View Results Tree侦听器中测试您的正则表达式实时响应

Jmeter正则表达式提取器变量不为第二个变量调用生成会话


In general when it comes to Regular Expressions and HTML you can never tell whether your expression provide a match or not as it depends on multiple factors and even a slight change in the markup, i.e. value you're looking for starts coming in 2 lines, will ruin your test so I would recommend to go for CSS/JQuery Extractor or XPath Extractor instead

一般来说,当涉及正则表达式和HTML时,你永远无法判断你的表达式是否提供匹配,因为它取决于多个因素,甚至标记的微小变化,即你正在寻找的值开始有2行,会破坏你的测试,所以我建议改用CSS / JQuery Extractor或XPath Extractor