远程VM重启后,通过Selenium远程webdriver重新启动浏览器

时间:2016-01-07 10:18:14

标签: selenium virtual-machine ui-automation remotewebdriver

我通过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");

0 个答案:

没有答案