我有一个 JMeter 作业正在网页上执行一些 UI 测试,然后它应该将对象的文本值存储在一个名为“impid”的变量中
var vars = org.apache.jmeter.threads.JMeterContextService.getContext().getVariables()
var importID = WDS.browser.findElement(org.openqa.selenium.By.xpath('html/body/table[2]/tbody/tr[3]/td[6]/table[1]/tbody/tr[5]/td[2]/strong')).getText()
vars.put('impid','importID')
我相信那部分工作正常,然后我想将该变量的值传递给 mysql JDBC 请求,就像这样 -
select id, fileName, timeEntered, timeStarted, timeCompleted, comments from netdespatch.fileImportStore where id = ${impid};
但是 varialbe 只是被用作“名称”,它没有被转换成变量值..
我确定有人知道我做错了什么..
最佳答案
I believe that part is working
你怎么知道?鉴于您的 XPath 语法,我认为它不匹配任何内容。
您的选择查询看起来不错,因此我建议您使用 Debug Sampler 仔细检查您的 ${impid}
变量和 View Results Tree听众组合。
您还可以尝试直接从 WebDriver Sampler 将变量值打印到 jmeter.log 文件中,例如:
WDS.log.info('importID value == ' + importID)
引用资料:
关于java - 如何在 JDBC 对象中使用变量? Jmeter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41266803/