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


Java DriverService类代码示例

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


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

示例1: getProxyDriverIntegrator

import org.openqa.selenium.remote.service.DriverService; //导入依赖的package包/类
private ProxyDriverIntegrator getProxyDriverIntegrator(RequestFilter recordRequestFilter,
                                                       WebDriverSupplier webDriverSupplier,
                                                       DriverServiceSupplier driverServiceSupplier,
                                                       @Named(PATH_TO_DRIVER) String pathToDriverExecutable,
                                                       @Named(SCREEN) String screen,
                                                       @Named(TIMEOUT) int timeout,
                                                       ResponseFilter responseFilter) throws IOException {
    BrowserMobProxy proxy = createBrowserMobProxy(timeout, recordRequestFilter, responseFilter);
    proxy.start(0);
    logger.info("Proxy running on port " + proxy.getPort());
    Proxy seleniumProxy = createSeleniumProxy(proxy);
    DesiredCapabilities desiredCapabilities = createDesiredCapabilities(seleniumProxy);
    DriverService driverService = driverServiceSupplier.getDriverService(pathToDriverExecutable, screen);
    WebDriver driver = webDriverSupplier.get(driverService, desiredCapabilities);

    return new ProxyDriverIntegrator(driver, proxy, driverService);
}
 
开发者ID:hristo-vrigazov,项目名称:bromium,代码行数:18,代码来源:DefaultModule.java

示例2: start

import org.openqa.selenium.remote.service.DriverService; //导入依赖的package包/类
public WebDriver start(DriverServiceFactory factory, DriverService driverService) {
    WebDriver driver = null;
    for (int i = 0; i < retries && driver == null; i++) {
        log.info("trying to start {}/{} (attempt/max attempts)", i, retries);
        driver = startServiceAndCreateWebdriver(driverService, factory);
        log.info("is started: {}", driver == null);
        if (driver == null) {
            try {
                timeUnit.sleep(2);
            } catch (InterruptedException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
    return driver;
}
 
开发者ID:lkwg82,项目名称:de.lgohlke.selenium-webdriver,代码行数:17,代码来源:RemoteWebdriverInitialConnectionRetryer.java

示例3: getDriverService

import org.openqa.selenium.remote.service.DriverService; //导入依赖的package包/类
public final DriverService getDriverService() {
    try {
        if (driverService == null) {
            driverService = createDriverService();
            wasRunning = driverService.isRunning();
            if (wasRunning) {
                LOGGER.info("Driver service {} is already running", driverService.getUrl());
            } else {
                driverService.start();
                LOGGER.info("Driver service {} started", driverService.getUrl());
            }
        }
        return driverService;
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:viltgroup,项目名称:minium,代码行数:18,代码来源:DriverServiceProperties.java

示例4: 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

示例5: getDriverService

import org.openqa.selenium.remote.service.DriverService; //导入依赖的package包/类
@Override
public DriverService getDriverService(String pathToDriverExecutable, String screenToUse) throws IOException {
    return getBuilder()
            .usingDriverExecutable(new File(pathToDriverExecutable))
            .usingAnyFreePort()
            .withEnvironment(ImmutableMap.of("DISPLAY", screenToUse))
            .build();
}
 
开发者ID:hristo-vrigazov,项目名称:bromium,代码行数:9,代码来源:DriverServiceSupplierBase.java

示例6: invokesTheCorrectMethodsOfTheBuilder

import org.openqa.selenium.remote.service.DriverService; //导入依赖的package包/类
@Test
public void invokesTheCorrectMethodsOfTheBuilder() throws IOException {
    DriverService.Builder builder = mock(DriverService.Builder.class, RETURNS_DEEP_STUBS);

    DriverServiceSupplierBase driverServiceSupplierBase = new DriverServiceSupplierBase() {
        @Override
        protected DriverService.Builder getBuilder() {
            return builder;
        }
    };

    DriverService driverService = driverServiceSupplierBase.getDriverService(driverExecutableFileName, screenToUse);

    verify(builder).usingDriverExecutable(eq(driverExecutableFile));
}
 
开发者ID:hristo-vrigazov,项目名称:bromium,代码行数:16,代码来源:DriverServiceSupplierBaseTest.java

示例7: providesAccessToConnectedDriverProxyAndDriverService

import org.openqa.selenium.remote.service.DriverService; //导入依赖的package包/类
@Test
public void providesAccessToConnectedDriverProxyAndDriverService() {
    WebDriver driver = mock(WebDriver.class);
    BrowserMobProxy proxy = mock(BrowserMobProxy.class);
    DriverService driverService = mock(DriverService.class);

    ProxyDriverIntegrator proxyDriverIntegrator = new ProxyDriverIntegrator(driver, proxy, driverService);

    assertEquals(driver, proxyDriverIntegrator.getWebDriver());
    assertEquals(proxy, proxyDriverIntegrator.getProxy());
    assertEquals(driverService, proxyDriverIntegrator.getDriverService());
}
 
开发者ID:hristo-vrigazov,项目名称:bromium,代码行数:13,代码来源:ProxyDriverIntegratorTest.java

示例8: 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

示例9: getDriver

import org.openqa.selenium.remote.service.DriverService; //导入依赖的package包/类
/**
 * Gets a web driver for a given browser
 * @param browser The browser to get a driver for
 * @return
 * @throws IOException
 */
public static synchronized RemoteWebDriver getDriver(Browser browser) throws IOException {
    if (global == null) {
        DriverService service = start(browser);
        global = new RemoteWebDriver(service.getUrl(), getDesiredBrowserCapabilities(browser));
        drivers.put(global, service);
    }
    return global;
}
 
开发者ID:Comcast,项目名称:dawg,代码行数:15,代码来源:BrowserServiceManager.java

示例10: 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

示例11: createDriverService

import org.openqa.selenium.remote.service.DriverService; //导入依赖的package包/类
@Override
protected DriverService createDriverService() {
    Builder builder = new ChromeDriverService.Builder();
    if (port != null) builder.usingPort(port);
    if (driverExecutable != null) builder.usingDriverExecutable(driverExecutable);
    if (environment != null) builder.withEnvironment(environment);
    if (logFile != null) builder.withLogFile(logFile);
    if (verbose != null) builder.withVerbose(verbose);
    if (silent != null) builder.withSilent(silent);
    return builder.build();
}
 
开发者ID:viltgroup,项目名称:minium,代码行数:12,代码来源:ChromeDriverServiceProperties.java

示例12: createDriverService

import org.openqa.selenium.remote.service.DriverService; //导入依赖的package包/类
@Override
protected DriverService createDriverService() {
    Builder builder = new GeckoDriverService.Builder();
    if (port != null) builder.usingPort(port);
    if (driverExecutable != null) builder.usingDriverExecutable(driverExecutable);
    if (environment != null) builder.withEnvironment(environment);
    if (logFile != null) builder.withLogFile(logFile);
    return builder.build();
}
 
开发者ID:viltgroup,项目名称:minium,代码行数:10,代码来源:FirefoxDriverServiceProperties.java

示例13: createDriverService

import org.openqa.selenium.remote.service.DriverService; //导入依赖的package包/类
@Override
public DriverService createDriverService() {
    Builder builder = new PhantomJSDriverService.Builder();

    if (driverExecutable != null) builder.usingPhantomJSExecutable(driverExecutable);
    if (ghostDriver != null) builder.usingGhostDriver(ghostDriver);
    if (port != null) builder.usingPort(port);
    if (environment != null) builder.withEnvironment(environment);
    if (logFile != null) builder.withLogFile(logFile);
    if (proxy != null) builder.withProxy(new Proxy(proxy));
    if (commandLineArguments != null) builder.usingCommandLineArguments(commandLineArguments);
    if (ghostDriverCommandLineArguments != null) builder.usingGhostDriverCommandLineArguments(ghostDriverCommandLineArguments);

    return builder.build();
}
 
开发者ID:viltgroup,项目名称:minium,代码行数:16,代码来源:PhantomJsDriverServiceProperties.java

示例14: createDriverService

import org.openqa.selenium.remote.service.DriverService; //导入依赖的package包/类
@Override
public DriverService createDriverService() {
    Builder builder = new InternetExplorerDriverService.Builder();
    if (port != null) builder.usingPort(port);
    if (driverExecutable != null) builder.usingDriverExecutable(driverExecutable);
    if (environment != null) builder.withEnvironment(environment);
    if (logFile != null) builder.withLogFile(logFile);
    if (logLevel != null) builder.withLogLevel(InternetExplorerDriverLogLevel.valueOf(logLevel.toUpperCase()));
    if (engineImplementation != null) builder.withEngineImplementation(InternetExplorerDriverEngine.valueOf(engineImplementation.toUpperCase()));
    if (host != null) builder.withHost(host);
    if (extractPath != null) builder.withExtractPath(extractPath);
    if (silent != null) builder.withSilent(silent);
    return builder.build();
}
 
开发者ID:viltgroup,项目名称:minium,代码行数:15,代码来源:InternetExplorerDriverServiceProperties.java

示例15: create

import org.openqa.selenium.remote.service.DriverService; //导入依赖的package包/类
@Override
public WebDriver create(WebDriverFactory webDriverFactory, DesiredCapabilities desiredCapabilities) {
    ChromeDriverServiceProperties serviceProperties = webDriverFactory.driverServices == null ? null : webDriverFactory.driverServices.getChrome();
    DriverService driverService = serviceProperties == null ? null : serviceProperties.getDriverService();
    return driverService == null ?
            new ChromeDriver(new ChromeOptions().merge(desiredCapabilities))
            : new RemoteWebDriver(driverService.getUrl(), desiredCapabilities);
}
 
开发者ID:viltgroup,项目名称:minium,代码行数:9,代码来源:WebDriverFactory.java


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