我通过selenium远程webdriver在远程VM上运行selenium脚本,对于每个测试,我将重新启动VM。下面是在VM重新启动后第二次浏览器启动失败时使用的示例程序。
WebDriver driver;
DesiredCapabilities capabilities=new DesiredCapabilities();
capabilities.setCapability("platformVersion", "40.0.2");
capabilities.setCapability("platformName", "WINDOWS");
capabilities.setCapability("browserName", "firefox");
driver= new RemoteWebDriver(new URL("http://10.86.101.217:4444/wd/hub"), capabilities);
driver.quit();
// Rebooting the VM, Selenium server started after rebooting
Thread.sleep(200000);
System.out.println("end");
driver= new RemoteWebDriver(new URL("http://10.86.101.217:4444/wd/hub"), capabilities);
Thread.sleep(3000);
System.out.println("end 2");