Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/389.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Selenium Grid,我想减少浏览器启动时间_Java_Selenium_Apache Commons_Selenium Grid - Fatal编程技术网

Java Selenium Grid,我想减少浏览器启动时间

Java Selenium Grid,我想减少浏览器启动时间,java,selenium,apache-commons,selenium-grid,Java,Selenium,Apache Commons,Selenium Grid,问题描述: 步骤如下: 1.我使用selenium-server-standalone-2.49.1.jar启动集线器和节点 java -jar selenium-server-standalone-2.49.1.jar -role hub -maxSession 40 java -jar selenium-server-standalone-2.49.1.jar -role node -hub http://localhost:4444/grid/register -browser b

问题描述:

步骤如下:

1.我使用selenium-server-standalone-2.49.1.jar启动集线器和节点

java -jar selenium-server-standalone-2.49.1.jar -role hub -maxSession 40
java -jar selenium-server-standalone-2.49.1.jar -role node  -hub    http://localhost:4444/grid/register -browser browserName=firefox,version=2.8,maxInstances=40,platform=LINUX
2.使用java编写代码:

String serverUrl=  "http://192.168.179.142:4444/wd/hub ";
DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setJavascriptEnabled(true);
WebDriver webDriver = new RemoteWebDriver(new URL(serverUrl), capability);webDriver.get("http://www.google.cn")
现在我的问题是: 当WebDriver被实例化时,它将花费3秒钟,对我来说,这3秒钟太长了。我想缩短这段时间,大约在1秒钟内。我该怎么做?
我想,我是否可以使用apache common-pool2,使用它创建一个WebDriver池。

您的服务器URL指向一台远程机器。因此,可能是网络延迟增加了时间。当您在本地网格上运行它时会发生什么情况[即,您的测试和网格设置都在同一台机器上]?你是否也看到了同样的时间?关于建立一个WebPosiver池,有很多事情你需要考虑,即,由于浏览器空闲,处理网格侧的浏览器清理,确保测试在浏览器运行完成后清除浏览器上的Cookie信息,因为现在您不会关闭浏览器,而只是共享它们。所以我不认为采用webdriver池方法是一个好主意感谢你的帮助@Krishnan Mahadevan