简体   繁体   English

JMeter WebDriver 采样器 - 无头 Firefox

[英]JMeter WebDriver Sampler - headless Firefox

Is it possible to run Firefox headless with WebDriver Sampler?是否可以使用 WebDriver Sampler 无头运行 Firefox? I have used the "Use Chrome headless mode" option with Chrome before, but I don't see that option in Firefox Driver Config.我之前在 Chrome 中使用过“使用 Chrome 无头模式”选项,但在 Firefox 驱动程序配置中没有看到该选项。

Perhaps this can be done in the actual sampler, by setting options to 'browser' in the code below?也许这可以通过在下面的代码中将选项设置为“浏览器”来在实际的采样器中完成?

WDS.sampleResult.sampleStart() 
WDS.browser.get('http://jmeter-plugins.org') 
WDS.sampleResult.sampleEnd()

Thank you.谢谢你。

There is no easy/GUI way of doing this using WebDriver Sampler (unless you patch FirefoxDriverConfig to include FirefoxBinary and pass to it --headless argument like:使用 WebDriver Sampler 没有简单的/GUI 方式来执行此操作(除非您修补FirefoxDriverConfig以包含FirefoxBinary并将--headless参数传递给它,例如:

FirefoxBinary firefoxBinary = new FirefoxBinary();
firefoxBinary.addCommandLineOptions("--headless");

Another option would be switching to JSR223 Sampler to initialise the FirefoxDriver class yourself from the scratch.另一种选择是切换到JSR223 Sampler以从头开始自己初始化 FirefoxDriver class。

More information: Firefox - Headless Mode更多信息: Firefox - 无头模式

And last but not the least, if you're about to execute your Selenium tests on ie Linux machine which doesn't have GUI you can create a virtual display using Xvfb so Firefox would run attached to this virtual desktop.最后但并非最不重要的一点是,如果您要在没有 GUI 的 Linux 机器上执行 Selenium 测试,您可以使用Xvfb创建虚拟显示器,因此 Z763F7F1AEC350CD1A46238D1D5 将运行附加到此虚拟桌面。 See Headless Execution of Selenium Tests in Jenkins for more details on implementing this on different operating systems.有关在不同操作系统上实现此功能的更多详细信息,请参阅Jenkins 中的 Selenium 测试的 Headless Execution

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM