You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Java代码调用jmeter-plugins-webdriver遇ExpectedConditions类未找到错误求助

Fixing ExpectedConditions NoClassDefFoundError in JMeter WebDriver Sampler

Hey there, let's troubleshoot this NoClassDefFoundError you're hitting with ExpectedConditions when using JMeter's WebDriver Sampler. Based on your setup details (JMeter 5.3, jmeter-plugins-webdriver 3.3, Selenium 3.141.59 dependency), here are the most likely fixes:

Common Causes & Solutions

1. Resolve Selenium Version Conflicts

JMeter or other installed plugins might be bringing in a different (older/newer) version of Selenium that either lacks ExpectedConditions or conflicts with the 3.141.59 version required by your WebDriver plugin.

  • Check your JMeter lib directories:
    • Navigate to your JMeter installation's lib and lib/ext folders.
    • Look for Selenium-related jars (like selenium-java-*.jar, selenium-support-*.jar).
    • Delete any versions that don't match 3.141.59. Only keep the jars corresponding to the Selenium version specified in the webdriver plugin's pom.

2. Reinstall the WebDriver Plugin via JMeter Plugins Manager

Manual jar downloads can sometimes miss required dependencies or result in corrupted files. Using the official plugins manager ensures all dependencies are correctly pulled and configured:

  • Open JMeter, go to Options > Plugins Manager.
  • Search for "WebDriver Sampler" (plugin name: jmeter-plugins-webdriver).
  • Uninstall the current 3.3 version, then reinstall it. This will automatically fetch all required Selenium 3.141.59 dependencies for you.

3. Adjust Jar Placement for Proper Class Loading

JMeter's class loader prioritizes jars in lib over lib/ext for core dependencies. If Selenium support jars are in the wrong folder, they might not be picked up by the WebDriver Sampler:

  • Move selenium-support-3.141.59.jar and other core Selenium jars from lib/ext to the main lib directory.
  • Keep only the jmeter-plugins-webdriver-3.3.jar in lib/ext (since it's a JMeter plugin).

4. Verify Your Code's Import & Usage

While your imports look correct, double-check for any subtle issues:

  • Ensure you're not accidentally importing a different ExpectedConditions class from another package.
  • For Selenium 3.x, the WebDriverWait constructor accepts a timeout in seconds as a long – your current code using Duration.ofSeconds(30).getSeconds() is valid, but you can simplify it to 30L for clarity:
    WebDriverWait wait = new WebDriverWait(WDS.browser, 30L);
    

Post-Fix Verification

After making these changes:

  1. Restart JMeter to clear any cached class files.
  2. Run your script again.
  3. Check the JMeter logs (via Options > Log Viewer) for any remaining class loading errors.

内容的提问来源于stack exchange,提问作者zongwlee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 07:25:55