如何通过机器人框架将值传递给jmeter的jmx文件中的用户定义变量 [英] How to pass values to the user defined variable in jmeter's jmx file via robot framework

查看:55
本文介绍了如何通过机器人框架将值传递给jmeter的jmx文件中的用户定义变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JMX文件,其中线程数(用户):"被定义为变量"$ {__ P(threads)}".

I have a JMX file in which "Number of Threads (users):" is defined as a variable "${__P(threads)}.

在机械手框架中,如何通过JMeterLib中定义的关键字将值传递到jmx文件中的此用户定义变量.

In robot-framework, how to pass values to this user defined variable in the jmx file via keywords defined in JMeterLib.

示例:如何在JMeterLib的以下关键字语法中包含相同内容:-

Example: How to include the same in the below keyword syntax of JMeterLib:-

run jmeter  D:/apache-jmeter-2.12/bin/jmeter.bat    D:/Tests/Test1Thread1Loop.jmx   D:/Tests/output1.jtl

推荐答案

更新此答案:

应使用以下语法执行命令[-Jthreads可以以'Jthreads = 10'或'Jthreads 10'的形式传递]:

The command should be executed using below syntax [-Jthreads can be passed as 'Jthreads=10' or 'Jthreads 10']:

run jmeter  D:/apache-jmeter-2.12/bin/jmeter.bat    D:/Tests/Test1Thread1Loop.jmx   D:/Tests/output1.jtl -Jthreads=10

但是,我仍然收到评论中更新的错误,以回应答案 https://stackoverflow.com/a/65889566/14795343 .感谢Dmitri T和github https://github.com/kowalpy/Robot-Framework-JMeter-Library/issues/6#issuecomment-793596283 .

But still, I was getting an error as updated in the comment in response to the answer https://stackoverflow.com/a/65889566/14795343. Thanks to Dmitri T and the response in github https://github.com/kowalpy/Robot-Framework-JMeter-Library/issues/6#issuecomment-793596283.

经过分析,发现发生此错误是因为机器人框架的jmeter库在我的测试环境中,https://github.com/kowalpy/Robot-Framework-JMeter-Library 在Python3版本中运行,但是库最初是在Python 2.7.5版本中开发的.简而言之,这归功于python版本的兼容性.

After analysis, it is found that this error occurred because the jmeter library for robot framework https://github.com/kowalpy/Robot-Framework-JMeter-Library is running in Python3 version in my test environment, but library is originally developed in Python 2.7.5 version. In nutshell, it due to python version compatibility.

因此,在类"JMeterClasses.py"中存在特定的命令.由于错误" AttributeError:module'string'has not attribute'split'" 被引发,因此在Python 3版本中无法识别.

And so, there is a particular command in the class "JMeterClasses.py" that was not recognized in Python 3 version due to which the error "AttributeError: module 'string' has no attribute 'split'" is thrown.

然后在"JMeterClasses.py"中更新了以下方法.

Then updated the below method in "JMeterClasses.py".

Old:
    def listOtherParams(self):
        self.params = []
        if not self.paramsStr == "":
            self.params = string.split(self.paramsStr)

Updated (string is modified as str, as highlighted below):
    def listOtherParams(self):
        self.params = []
        if not self.paramsStr == "":
            self.params = str.split(self.paramsStr)

修改上述方法后,它对我有用.

It worked for me after modifying the above method.

注意:您可以找到"JMeterClasses.py"在site-packages/dist-packages文件夹中[示例路径:/usr/local/lib/python3.8/dist-packages/].

Note: You can find the "JMeterClasses.py" in the site-packages/dist-packages folder [Example Path: /usr/local/lib/python3.8/dist-packages/].

这篇关于如何通过机器人框架将值传递给jmeter的jmx文件中的用户定义变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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