英文:
Get error when run WebDriver Sampler in jmeter
问题
我尝试为我的网站进行性能测试。在这个测试中,我使用了JMeter,并已经创建了测试计划。
这是项目
我仍然在遇到以下错误,不知道如何解决:
2023-07-04 19:32:06,010 ERROR o.a.j.JMeter: Uncaught exception in thread Thread[Thread Group 1-1,6,main]
java.lang.NoSuchMethodError: 'com.google.common.collect.ImmutableMap com.google.common.collect.ImmutableMap.of(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object)'
at org.openqa.selenium.chrome.AddHasCasting.getAdditionalCommands(AddHasCasting.java:38) ~[selenium-chrome-driver-4.9.1.jar:?]
at org.openqa.selenium.chrome.ChromeDriver$ChromeDriverCommandExecutor.getExtraCommands(ChromeDriver.java:116) ~[selenium-chrome-driver-4.9.1.jar:?]
at org.openqa.selenium.chrome.ChromeDriver$ChromeDriverCommandExecutor.<init>(ChromeDriver.java:111) ~[selenium-chrome-driver-4.9.1.jar:?]
at org.openqa.selenium.chrome.ChromeDriver.generateExecutor(ChromeDriver.java:101) ~[selenium-chrome-driver-4.9.1.jar:?]
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:88) ~[selenium-chrome-driver-4.9.1.jar:?]
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:84) ~[selenium-chrome-driver-4.9.1.jar:?]
at com.googlecode.jmeter.plugins.webdriver.config.ChromeDriverConfig.createBrowser(ChromeDriverConfig.java:28) ~[jmeter-plugins-webdriver-4.9.1.0.jar:?]
at com.googlecode.jmeter.plugins.webdriver.config.ChromeDriverConfig.createBrowser(ChromeDriverConfig.java:14) ~[jmeter-plugins-webdriver-4.9.1.0.jar:?]
at com.googlecode.jmeter.plugins.webdriver.config.WebDriverConfig.getPreparedBrowser(WebDriverConfig.java:221) ~[jmeter-plugins-webdriver-4.9.1.0.jar:?]
at com.googlecode.jmeter.plugins.webdriver.config.WebDriverConfig.threadStarted(WebDriverConfig.java:152) ~[jmeter-plugins-webdriver-4.9.1.0.jar:?]
at org.apache.jmeter.threads.JMeterThread$ThreadListenerTraverser.addNode(JMeterThread.java:802) ~[ApacheJMeter_core.jar:5.6]
at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:1029) ~[jorphan.jar:5.6]
at org.apache.jorphan.collections.HashTree.traverse(HashTree.java:1012) ~[jorphan.jar:5.6]
at org.apache.jmeter.threads.JMeterThread.threadStarted(JMeterThread.java:770) ~[ApacheJMeter_core.jar:5.6]
at org.apache.jmeter.threads.JMeterThread.initRun(JMeterThread.java:758) ~[ApacheJMeter_core.jar:5.6]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:264) ~[ApacheJMeter_core.jar:5.6]
at java.lang.Thread.run(Thread.java:833) [?:?]
2023-07-04 19:32:06,010 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test
2023-07-04 19:32:06,011 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, *local*)
我尝试了一切都没有成功。
英文:
i try to do performance test for my website . i use jmeter in this test and i created already Test plan.
this is the project
i still getting the below error and i don't know how to solve
2023-07-04 19:32:06,010 ERROR o.a.j.JMeter: Uncaught exception in thread Thread[Thread Group 1-1,6,main]
java.lang.NoSuchMethodError: 'com.google.common.collect.ImmutableMap com.google.common.collect.ImmutableMap.of(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object)'
at org.openqa.selenium.chrome.AddHasCasting.getAdditionalCommands(AddHasCasting.java:38) ~[selenium-chrome-driver-4.9.1.jar:?]
at org.openqa.selenium.chrome.ChromeDriver$ChromeDriverCommandExecutor.getExtraCommands(ChromeDriver.java:116) ~[selenium-chrome-driver-4.9.1.jar:?]
at org.openqa.selenium.chrome.ChromeDriver$ChromeDriverCommandExecutor.<init>(ChromeDriver.java:111) ~[selenium-chrome-driver-4.9.1.jar:?]
at org.openqa.selenium.chrome.ChromeDriver.generateExecutor(ChromeDriver.java:101) ~[selenium-chrome-driver-4.9.1.jar:?]
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:88) ~[selenium-chrome-driver-4.9.1.jar:?]
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:84) ~[selenium-chrome-driver-4.9.1.jar:?]
at com.googlecode.jmeter.plugins.webdriver.config.ChromeDriverConfig.createBrowser(ChromeDriverConfig.java:28) ~[jmeter-plugins-webdriver-4.9.1.0.jar:?]
at com.googlecode.jmeter.plugins.webdriver.config.ChromeDriverConfig.createBrowser(ChromeDriverConfig.java:14) ~[jmeter-plugins-webdriver-4.9.1.0.jar:?]
at com.googlecode.jmeter.plugins.webdriver.config.WebDriverConfig.getPreparedBrowser(WebDriverConfig.java:221) ~[jmeter-plugins-webdriver-4.9.1.0.jar:?]
at com.googlecode.jmeter.plugins.webdriver.config.WebDriverConfig.threadStarted(WebDriverConfig.java:152) ~[jmeter-plugins-webdriver-4.9.1.0.jar:?]
at org.apache.jmeter.threads.JMeterThread$ThreadListenerTraverser.addNode(JMeterThread.java:802) ~[ApacheJMeter_core.jar:5.6]
at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:1029) ~[jorphan.jar:5.6]
at org.apache.jorphan.collections.HashTree.traverse(HashTree.java:1012) ~[jorphan.jar:5.6]
at org.apache.jmeter.threads.JMeterThread.threadStarted(JMeterThread.java:770) ~[ApacheJMeter_core.jar:5.6]
at org.apache.jmeter.threads.JMeterThread.initRun(JMeterThread.java:758) ~[ApacheJMeter_core.jar:5.6]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:264) ~[ApacheJMeter_core.jar:5.6]
at java.lang.Thread.run(Thread.java:833) [?:?]
2023-07-04 19:32:06,010 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test
2023-07-04 19:32:06,011 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, *local*)
i tried everything with no chance
答案1
得分: 0
我无法重现你的问题,很可能你遇到了一种Jar Hell的问题,尝试对JMeter和WebDriver Sampler插件进行干净的安装,问题应该会消失。
一般来说,关于你的“我尝试对我的网站进行性能测试”部分,我不认为使用Selenium是一个好主意,主要因为:
-
使用WebDriver Sampler无法像正常的HTTP请求采样器那样生成大量负载,因为WebDriver Sampler启动了一个真实的浏览器,而浏览器对资源要求很高。
-
这并不被Selenium的开发者所推荐。3
使用Selenium和WebDriver进行性能测试通常不被推荐。不是因为它无法做到,而是因为它没有针对这项任务进行优化,你很难获得好的结果。
-
这也不被WebDriver Sampler插件的开发者所推荐。4
注意:本项目的目的不是取代JMeter中包含的HTTP采样器,而是通过测量最终用户的加载时间来补充它们。
因此,我建议重新考虑你的方法,转而使用HTTP请求采样器,如果你配置JMeter以像真实浏览器一样运行,你的测试将生成与浏览器相同的网络足迹,但资源消耗要少得多,并且生成的指标要好得多。
英文:
I cannot reproduce your issue, most probably you're suffering from a form of a Jar Hell, perform clean installation of JMeter and WebDriver Sampler plugin and the issue will go away.
In general with regards to your "i try to do performance test for my website" stanza I don't think using Selenium is a good idea mainly because:
-
You won't be able to generate that many load with the WebDriver Sampler as with normal HTTP Request sampler because WebDriver Sampler kicks off a real browser and browsers are very resource intensive
-
It's not recommended by Selenium developers
>Performance testing using Selenium and WebDriver is generally not advised. Not because it is incapable, but because it is not optimised for the job and you are unlikely to get good results. -
It's not recommended by WebDriver Sampler plugin developers
>Note: It is NOT the intention of this project to replace the HTTP Samplers included in JMeter. Rather it is meant to compliment them by measuring the end user load time.
So I would suggest reconsidering your approach and switch to HTTP Request samplers, given you configure JMeter to behave like a real browser your test will generate the same network footprint as the browser does with much less resources consumption and much better metrics generated.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论