0

I have some already working selenium scripts written in python. But, my current use case is to run them through jmeter.

I know I can add webdriver sampler in jmeter to integrate selenium with jmeter. But what if the scripts are written in python?

Is it possible or I need to convert my scripts to java?

4
  • To execute Python scripts, you should use JSR223 sampler, not the web driver. WebDriver supports only Java. But JSR223 sampler supports Python, Groovy etc. Commented Mar 26, 2017 at 13:50
  • As my current installation suggests JSR223 sampler doesn't have python as language option, though it does support groovy. Commented Mar 26, 2017 at 13:58
  • Can you try with OS Process Sampler? Commented Mar 26, 2017 at 17:57
  • Also you can use BeanShell processor to execute your python script. Commented Mar 26, 2017 at 17:58

2 Answers 2

3

It depends on what you are trying to achieve:

  1. If you need to simply "run" tests as they are, you can:
  • Download Jython jar

  • Put it under "lib" folder of your JMeter installation

  • Restart JMeter

  • See "jython/python" scripting option under JSR223 Test Elements

    JMeter Python Selenium

  1. If you want your Selenium tests to be executed in parallel with existing JMeter test the easiest option would be using Taurus tool for executing both JMeter and Selenium at the same time.

  2. If you need to use your Python Selenium tests for creating the load, converting them to JMeter format will be a much better idea as using real browsers memory footprint is huge therefore you won't be able to conduct more or less immense load.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the answer. I think this covers the whole scenario, though I am only interested in use case #1.
I am able to run simple python code with your above solution (placing jython jar inside lib). But, I can't run selenium code. That's probably because selenium isn't installed in my jython. I searched a lot, but can't figure out how to install a python module so that it works with a jython jar. Would you please add this to the answer?
Dimitri, I am encountering this issue also. In item no.1 above, the Jython link is a dead link, I am wondering if you can show what should the jython link lead to?
0

(Adding as an answer as i'm 4 points from commenting)

Jython works.

I would suggest looking at Locust.io. It's python's answer to jmeeter. It's free. It's python native, so one can easily port into it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.