多个Selenium Grid 2测试:如何在Firefox中运行隐藏的Windows浏览器

时间:2015-08-03 11:54:41

标签: java firefox selenium-grid2

我想用50个并行的Firefox独立浏览器实例(或更多)运行Selenium Grid 2测试。但是如果所有这些浏览器窗口打开,它需要大量的机器内存。出于这个原因,我想用隐藏的Firefox窗口运行测试。如何在后台使用Firefox窗口运行此测试。我试过了:

DesiredCapabilities capability = new DesiredCapabilities();
capability = DesiredCapabilities.firefox();
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.tabs.loadDivertedInBackground", true);
capability.setCapability(FirefoxDriver.PROFILE, profile);

但它没有用。任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

请考虑使用HTMLUnitDriver。这将确保没有启动UI。这是进行健全性测试的高效且经过验证的方法。

HtmlUnitDriver driver = new HtmlUnitDriver(DesiredCapabilities.firefox());
driver.get("http://anysiteurl");
driver.quit();