问答 metersphere 提取参数后怎么调用?

我有一块大洋 · 2022年03月07日 · 最后由 醋精测试媛 回复于 2022年05月06日 · 4996 次阅读

例如我在登陆接口里面提取了 token

在下一个接口里面的请求头想要调用已提取的 token 参数是这样提取的吗?

共收到 4 条回复 时间 点赞
仅楼主可见

要在具有上下文的运行中才有效,在接口自动化的场景里面这样用是对的。

我也想问一下,如何在后面的 beanshell 脚本中使用?试过了 ${variable}会报错:

2022-05-06 09:56:34 ERROR 03929a41 1-1 Problem in JSR223 script, JSR223PreProcessor
Sourced file: inline evaluation of: ``log.info("log:"); log.info(${scenes}) ;'' : Attempt to access property on undefined variable or class name : at Line: 2 : in file: inline evaluation of: ``log.info("log:"); log.info(${scenes}) ;'' : { 
 in inline evaluation of: ``log.info("log:"); log.info(${scenes}) ;'' at line number 2
javax.script.ScriptException
   at bsh.engine.BshScriptEngine.evalSource(BshScriptEngine.java:93)
   at bsh.engine.BshScriptEngine.eval(BshScriptEngine.java:46)
   at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)
   at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:253)
   at org.apache.jmeter.modifiers.JSR223PreProcessor.process(JSR223PreProcessor.java:45)
   at org.apache.jmeter.threads.JMeterThread.runPreProcessors(JMeterThread.java:981)
   at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546)
   at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486)
   at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:250)
   at java.lang.Thread.run(Thread.java:748)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册