简体   繁体   中英

How do you add a jp@gc - Remote Driver Config to a JMeter test using java code

I am trying to add a RemoteDriverConfig element to an existing JMeter test using java code, and then proceed to run the JMeter test on my existing selenium hub and nodes. I am not trying to write selenium tests in JMeter or anything like that, just using the node to run an API JMeter test. When I create a new “RemoteDriverConfig” object to add to the Jmeter test, I am getting the following failure: "Message: java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException”.

Here is a code snippet (just using chrome for the Capability):

import com.googlecode.jmeter.plugins.webdriver.config.RemoteDriverConfig;

RemoteDriverConfig seleniumHubConfig = new RemoteDriverConfig();
seleniumHubConfig.setCapability(RemoteCapability.CHROME);
seleniumHubConfig.setSeleniumGridUrl(remoteUrl);
testPlanTree.add("remoteDriverConfig", seleniumHubConfig);

Any and all help is greatly appreciated.

EDIT: This is the list of imports

<dependency>
    <groupId>org.apache.jmeter</groupId>
    <artifactId>ApacheJMeter_core</artifactId>
    <version>3.3</version>
</dependency>
<dependency>
    <groupId>org.apache.jmeter</groupId>
    <artifactId>ApacheJMeter_components</artifactId>
    <version>3.3</version>
</dependency>
<dependency>
    <groupId>org.apache.jmeter</groupId>
    <artifactId>jorphan</artifactId>
    <version>3.3</version>
</dependency>
<dependency>
    <groupId>org.apache.jmeter</groupId>
    <artifactId>ApacheJMeter_java</artifactId>
    <version>3.3</version>
</dependency>
<dependency>
    <groupId>org.apache.jmeter</groupId>
    <artifactId>ApacheJMeter_http</artifactId>
    <version>3.3</version>
</dependency>
<dependency>
    <groupId>kg.apc</groupId>
    <artifactId>jmeter-plugins-webdriver</artifactId>
    <version>2.2</version>
    </dependency>

As per NoClassDefFoundError JavaDoc

Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.

My expectation is that your installation of JMeter WebDriver Sampler Plugin is broken or incomplete as you simply seem to be missing some Selenium core libraries in your CLASSPATH .

If you are trying to do this from JMeter - I would recommend installing clean JMeter instance (get latest version available at the JMeter Downloads page) and add WebDriver support via JMeter Plugins Manager - it will automatically handle dependencies.

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