2017-05-29 121 views
1

您好, 我正在使用jmeter進行junit負載測試。爲此,我正在使用硒webdriver並使用硒junit測試來運行它。當我運行這個代碼與硒webdriver junit,其工作正常。但是當我試圖用jmeter中的20個線程做同樣的事情時,那麼我正面臨以下問題。jmeter的junit請求採樣器等待條件不起作用

Error -- test(org.apache.jmeter.protocol.java.sampler.JUnitSampler$AnnotatedTestCase): org.openqa.selenium.support.ui.WebDriverWait.until(Ljava/util/function/Function;)Ljava/lang/Object; 
Trace -- java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.WebDriverWait.until(Ljava/util/function/Function;)Ljava/lang/Object; 
    at SeleniumTestNG.LoginLogoutTest.test(LoginLogoutTest.java:55) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.apache.jmeter.protocol.java.sampler.JUnitSampler$AnnotatedTestCase.runTest(JUnitSampler.java:593) 
    at org.apache.jmeter.protocol.java.sampler.JUnitSampler$1.protect(JUnitSampler.java:673) 
    at junit.framework.TestResult.runProtected(TestResult.java:142) 
    at org.apache.jmeter.protocol.java.sampler.JUnitSampler.sample(JUnitSampler.java:395) 
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:491) 
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:425) 
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:254) 
    at java.lang.Thread.run(Unknown Source) 
Error -- test(org.apache.jmeter.protocol.java.sampler.JUnitSampler$AnnotatedTestCase): org.openqa.selenium.support.ui.WebDriverWait.until(Ljava/util/function/Function;)Ljava/lang/Object; 
Trace -- java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.WebDriverWait.until(Ljava/util/function/Function;)Ljava/lang/Object; 
    at SeleniumTestNG.LoginLogoutTest.tearDown(LoginLogoutTest.java:83) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.apache.jmeter.protocol.java.sampler.JUnitSampler.sample(JUnitSampler.java:399) 
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:491) 
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:425) 
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:254) 
    at java.lang.Thread.run(Unknown Source) 

請幫我解決這個問題。

+0

可能的重複[如何修復NoSuchMethodError?](https://stackoverflow.com/questions/35186/how-doi-i-fix-a-nosuchmethoderror) – crizzis

回答

0

只要確保你從獨立JUnit項目中的所有庫中跳過JMeter Classpath,因爲它看起來像是患有this issue或衍生產品。

今後確保您的問題包括:

  • 代碼,您正試圖運行項目的
  • 依賴庫的安裝Jmeter的「LIB」文件夾中的
  • 內容
  • jmeter.log文件

另請注意,有WebDriver Sampler可通過JMeter Plugins提供JMeter和Selenium集成的項目,這樣測試開發將會快得多,因爲您不必重新編譯模塊,將jar複製到JMeter的「lib/junit」文件夾,重新啓動JMeter等。