简体   繁体   中英

How to install additional packages to jython jar in jmeter?

I am using jython inside jmeter by placing the jython.jar under "lib" folder of your JMeter installation. It runs successfully.

But the problem is I can't install additional packages or modules of python inside it. To be more specific, I want to run selenium in python inside jmeter, so needs selenium module needs to be installed in jython.

How should I do it?

You can install Jython packages normally, ie using pip , however make sure you are executing pip which comes with Jython (located under "bin" folder of your Jython installation)

  1. Download Jython installer and perform the installation somewhere, ie /temp/jython
  2. Navigate to /temp/jython/bin folder and execute ./pip install selenium command
  3. Add the next line to user.properties file which is located in JMeter's "bin" folder:

     user.classpath=/temp/jython;/temp/jython/javalib 

    Note that JMeter restart will be required to pick the classpath up, check out Apache JMeter Properties Customization Guide for more information.

  4. Add JSR223 Sampler and selenium jython from the "Language" dropdown

  5. Add the next lines at the beginning of your script:

     import sys sys.path.append('/temp/jython/Lib') sys.path.append('/temp/jython/Lib/site-packages') import selenium 

You should be good to go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM