当前位置: 首页>>代码示例>>Java>>正文


Java DriverService.start方法代码示例

本文整理汇总了Java中org.openqa.selenium.remote.service.DriverService.start方法的典型用法代码示例。如果您正苦于以下问题:Java DriverService.start方法的具体用法?Java DriverService.start怎么用?Java DriverService.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openqa.selenium.remote.service.DriverService的用法示例。


在下文中一共展示了DriverService.start方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createWebDriver

import org.openqa.selenium.remote.service.DriverService; //导入方法依赖的package包/类
public WebDriverEx createWebDriver(DriverService driverService,
                                      DesiredCapabilities desiredCapabilities,
                                      SiteConfig siteConfig,
                                      DriverConfig driverConfig) throws IOException {
    driverService.start();

    //自定义HttpClientFactory用于设置命令超时时间
    ApacheHttpClient.Factory httpClientFactory = createHttpClientFactory(siteConfig, driverConfig);
    HttpCommandExecutor httpCommandExecutor = new HttpCommandExecutor(
            ImmutableMap.<String, CommandInfo>of(), driverService.getUrl(), httpClientFactory);
    WebDriverEx webDriver = new WebDriverEx(httpCommandExecutor, desiredCapabilities);
    webDriver.setDriverService(driverService);
    webDriver.setCreatedTime(new Date());

    webDriver.manage().timeouts().implicitlyWait(driverConfig.getImplicitlyWait(), TimeUnit.MILLISECONDS);
    webDriver.manage().timeouts().pageLoadTimeout(driverConfig.getPageLoadTimeout(), TimeUnit.MILLISECONDS);
    webDriver.manage().timeouts().setScriptTimeout(driverConfig.getScriptTimeout(), TimeUnit.MILLISECONDS);

    return webDriver;
}
 
开发者ID:brucezee,项目名称:jspider,代码行数:21,代码来源:WebDriverFactory.java

示例2: startServiceAndCreateWebdriver

import org.openqa.selenium.remote.service.DriverService; //导入方法依赖的package包/类
private WebDriver startServiceAndCreateWebdriver(DriverService driverService, DriverServiceFactory factory) {
    ExecutorService service = Executors.newFixedThreadPool(1);

    @SuppressWarnings("unchecked")
    Callable<WebDriver> startJob = () -> {
        if (!driverService.isRunning()) {
            log.info("starting");
            driverService.start();
        }
        log.info("try to create webdriver");
        return factory.createWebDriver(driverService);
    };

    Future<WebDriver> startFuture = service.submit(startJob);
    try {
        log.info("waiting for webdriver");
        return startFuture.get(timeout, timeUnit);
    } catch (ExecutionException | InterruptedException | TimeoutException e) {
        log.warn(e.getMessage(), e);
        if (driverService.isRunning()) {
            driverService.stop();
        }
    } finally {
        service.shutdownNow();
    }
    return null;
}
 
开发者ID:lkwg82,项目名称:de.lgohlke.selenium-webdriver,代码行数:28,代码来源:RemoteWebdriverInitialConnectionRetryer.java

示例3: start

import org.openqa.selenium.remote.service.DriverService; //导入方法依赖的package包/类
/**
 * Starts a selenium service for a given browser
 * @param browser The browser to start the service for
 * @return
 * @throws IOException
 */
public static DriverService start(Browser browser) throws IOException {
    BrowserDriverProvider provider = getProvider(browser);
    DriverService service = new ChromeDriverService.Builder().usingDriverExecutable(provider.getDriverFile()).usingAnyFreePort().build();
    service.start();
    return service;
}
 
开发者ID:Comcast,项目名称:dawg,代码行数:13,代码来源:BrowserServiceManager.java


注:本文中的org.openqa.selenium.remote.service.DriverService.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。