Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query: How to pass values to the user defined variable in jmeter's jmx file via robot framework #6

Open
chidambaranathan-r opened this issue Jan 26, 2021 · 2 comments

Comments

@chidambaranathan-r
Copy link

robot-framework version = 3.2.2 ; Python version = 3.9.0 ; jmeter version = 5.4.1

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

In robot-framework, how to pass values to this user defined variable in the jmx file via keywords defined in 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

I tried the below:

run jmeter ${jmeter_install_path} ${jmeter_jmx_path} ${jmeter_log_path} -Jthreads=10

but it thrown below error,

"AttributeError: module 'string' has no attribute 'split'"

Can I get some clue on how to solve this?

@kowalpy
Copy link
Owner

kowalpy commented Feb 7, 2021

Try not using equal sign, for example: -Jthreads 10. Let me know if it helped.

@chidambaranathan-r
Copy link
Author

chidambaranathan-r commented Mar 9, 2021

Without using equal sign it works. Thanks. But I was getting error "AttributeError: module 'string' has no attribute 'split'".

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.

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.

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.

One more query:
Can we pass more than one variable fro JMX file. For example "${__P(threads)}" and ""${__P(token)}? I tried but it throws error like "Keyword 'JMeterLib.Run Jmeter' expected 3 to 4 arguments, got 5.".

It seems currently it is restricted to have only max 4 arguments. Any idea or way forward to include more variable that is defined in the JMX configuration file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants