如何在 Webdriver-Sampler 中传递变量 |Jmeter 网络驱动程序 [英] How to pass variable in Webdriver-Sampler | Jmeter Webdriver

查看:26
本文介绍了如何在 Webdriver-Sampler 中传递变量 |Jmeter 网络驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了一个包含超过 8 个 Webdriver-Sampler 的测试脚本和一个变量,它在某些 Webdriver-Sampler 中发生了变化.

例如:

第一采样器:status = "登录成功"

第二个采样器: status =登录成功,搜索失败"

第三个采样器: status = "登录成功,搜索失败,注销成功"

所以我必须每次都传递变量,然后编辑这个变量.我知道可以传递关于参数字段的变量.但是如何在脚本中编辑用户定义变量?

解决方案

您可以访问

参见 WebDriver 采样器:您回答的前 10 个问题 有关更多 WebDriver Sampler 提示和技巧的指南

I got a Testscript with more than 8 Webdriver-Sampler and a variable, which change in some of the Webdriver-Sampler.

For Example:

First Sampler: status = "login successful"

Second Sampler: status = "login successful, search for something failed"

Third Sampler: status = "login successful, search for something failed, logout successful"

So I have to pass the variable everytime and then edit this variable. I know it is possible to pass a varibale about the Parameter-field. But how can I edit a user define variable in script?

解决方案

You can access JMeterVariables class instance via JMeterContext.getVariables() method like:

var vars = org.apache.jmeter.threads.JMeterContextService.getContext().getVariables()
vars.put('foo','bar')
var foo = vars.get('foo')
//etc

See The WebDriver Sampler: Your Top 10 Questions Answered guide for more WebDriver Sampler tips and tricks

这篇关于如何在 Webdriver-Sampler 中传递变量 |Jmeter 网络驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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