jmeter 设置代理选项时,Selenium节点的toml配置不起作用

f87krz0w  于 2023-10-20  发布在  其他
关注(0)|答案(1)|浏览(105)

我正在拼命尝试启动一个Selenium节点(Selenium standalone 4.13.0),以便使用远程Linux vm通过jmeter/jmeter-server工具(通过rmi)运行一些性能测试。我必须使用自定义代理设置启动firefox的会话,所以我尝试启动selenium节点,包括CL中的toml配置文件的引用。
我这样写这个文件,试图正确插入设置代理所需的内容:

[node]
detect-drivers = false

[[node.driver-configuration]]
display-name = "firefox"
stereotype = "{\"browserName\": \"firefox\", \"browserVersion\": \"118\", \"platformName\": \"LINUX\", \"acceptSslCerts\": true, \"acceptInsecureCerts\": true, \"proxy\": {\"httpProxy\": \"http://...:80\", \"proxyType\": \"manual\", \"noProxy\": \"172.*;*.local\"}, \"moz:firefoxOptions\": {\"binary\": \"/usr/local/firefox/firefox-bin\"}}"
log-level = "trace"
webdriver-executable = "/usr/local/bin/geckodriver"
session-timeout = 30

重要的是,我必须指定“noProxy”字段来插入异常列表。无论如何,每次我尝试远程启动测试时,它都会卡住,因为远程Web驱动程序似乎无法与selenium grid通信。
selenium-server的完整日志如下:

2023-10-02 12:56:58,417 ERROR o.a.j.t.JMeterThread: Error calling threadStarted
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. 
Host info: host: 'BDM_AS_01', ip: '10.6.197.103'
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:561) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:229) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139) ~[selenium-remote-driver-4.8.3.jar:?]
    at com.googlecode.jmeter.plugins.webdriver.config.RemoteDriverConfig.createBrowser(RemoteDriverConfig.java:25) ~[jmeter-plugins-webdriver-4.10.0.0.jar:?]
    at com.googlecode.jmeter.plugins.webdriver.config.RemoteDriverConfig.createBrowser(RemoteDriverConfig.java:13) ~[jmeter-plugins-webdriver-4.10.0.0.jar:?]
    at com.googlecode.jmeter.plugins.webdriver.config.WebDriverConfig.getPreparedBrowser(WebDriverConfig.java:221) ~[jmeter-plugins-webdriver-4.10.0.0.jar:?]
    at com.googlecode.jmeter.plugins.webdriver.config.WebDriverConfig.threadStarted(WebDriverConfig.java:152) ~[jmeter-plugins-webdriver-4.10.0.0.jar:?]
    at org.apache.jmeter.threads.JMeterThread$ThreadListenerTraverser.addNode(JMeterThread.java:797) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:993) ~[jorphan.jar:5.5]
    at org.apache.jorphan.collections.HashTree.traverse(HashTree.java:976) ~[jorphan.jar:5.5]
    at org.apache.jmeter.threads.JMeterThread.threadStarted(JMeterThread.java:765) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.threads.JMeterThread.initRun(JMeterThread.java:753) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:264) ~[ApacheJMeter_core.jar:5.5]
    at java.lang.Thread.run(Thread.java:750) ~[?:1.8.0_345]
Caused by: org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
Build info: version: '4.8.3', revision: 'e5e76298c3'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '4.18.0-425.3.1.el8.x86_64', java.version: '1.8.0_345'
Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:65) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42) ~[selenium-http-4.8.3.jar:?]
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56) ~[selenium-http-4.8.3.jar:?]
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42) ~[selenium-http-4.8.3.jar:?]
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56) ~[selenium-http-4.8.3.jar:?]
    at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:99) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:124) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:106) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:165) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543) ~[selenium-remote-driver-4.8.3.jar:?]
    ... 14 more
Caused by: java.util.concurrent.TimeoutException
    at java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1784) ~[?:1.8.0_345]
    at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1928) ~[?:1.8.0_345]
    at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:206) ~[async-http-client-2.12.3.jar:?]
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:59) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42) ~[selenium-http-4.8.3.jar:?]
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56) ~[selenium-http-4.8.3.jar:?]
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42) ~[selenium-http-4.8.3.jar:?]
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56) ~[selenium-http-4.8.3.jar:?]
    at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:99) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:124) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:106) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:165) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51) ~[selenium-remote-driver-4.8.3.jar:?]
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543) ~[selenium-remote-driver-4.8.3.jar:?]
    ... 14 more
2023-10-02 12:56:58,426 INFO o.a.j.s.FileServer: Stored: credenziali_front.csv
2023-10-02 12:56:58,427 ERROR o.a.j.t.JMeterThread: Error while processing sampler: 'Clear Cookie (in attesa di LOGOUT)'.
java.lang.IllegalArgumentException: Browser has not been configured.  Please ensure at least 1 WebDriverConfig is created for a ThreadGroup.
    at com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler.sample(WebDriverSampler.java:65) ~[jmeter-plugins-webdriver-4.10.0.0.jar:?]
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:651) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:570) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:501) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:268) ~[ApacheJMeter_core.jar:5.5]
    at java.lang.Thread.run(Thread.java:750) ~[?:1.8.0_345]
2023-10-02 12:56:58,427 ERROR o.a.j.t.JMeterThread: Error while processing sampler: 'Login'.
java.lang.IllegalArgumentException: Browser has not been configured.  Please ensure at least 1 WebDriverConfig is created for a ThreadGroup.
    at com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler.sample(WebDriverSampler.java:65) ~[jmeter-plugins-webdriver-4.10.0.0.jar:?]
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:651) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:570) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:501) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:268) ~[ApacheJMeter_core.jar:5.5]
    at java.lang.Thread.run(Thread.java:750) ~[?:1.8.0_345]
2023-10-02 12:56:58,427 ERROR o.a.j.t.JMeterThread: Error while processing sampler: 'Logout'.
java.lang.IllegalArgumentException: Browser has not been configured.  Please ensure at least 1 WebDriverConfig is created for a ThreadGroup.
    at com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler.sample(WebDriverSampler.java:65) ~[jmeter-plugins-webdriver-4.10.0.0.jar:?]
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:651) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:570) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:501) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:268) ~[ApacheJMeter_core.jar:5.5]
    at java.lang.Thread.run(Thread.java:750) ~[?:1.8.0_345]

最后一个错误是浏览器没有正确配置。错在哪里?先谢谢你了。

lhcgjxsq

lhcgjxsq1#

如果你使用的是WebDriver Sampler,你不需要自己启动Firefox示例,Firefox Driver Config会处理它。也可以在此处指定代理设置:

另请注意:

通常不建议使用Selenium和WebDriver进行性能测试。不是因为它没有能力,而是因为它没有为工作进行优化,你不太可能得到好的结果。

注意:本项目无意替换JMeter中包含的HTTP采样器。相反,它是为了通过测量最终用户加载时间来补充它们。
因此,我建议考虑使用configuring JMeter to behave like a real browser并使用HTTP请求采样器。您将使用更少的资源产生相同的网络足迹。

相关问题