Java 类org.openqa.selenium.chrome.ChromeDriverService 实例源码
项目:alex
文件:ChromeDriverConfig.java
@Override
public WebDriver createDriver() throws Exception {
final ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--no-sandbox");
if (headless) {
chromeOptions.setHeadless(true);
}
final Map<String, String> environmentVariables = new HashMap<>();
if (!headless && xvfbPort != null) {
environmentVariables.put("DISPLAY", ":" + String.valueOf(xvfbPort));
}
final ChromeDriverService service = new ChromeDriverService.Builder()
.usingAnyFreePort()
.withEnvironment(environmentVariables)
.build();
final WebDriver driver = new ChromeDriver(service, chromeOptions);
manage(driver);
return driver;
}
项目:Bytecoder
文件:BytecoderUnitTestRunner.java
private static void initializeSeleniumDriver() throws IOException {
if (DRIVERSERVICE == null) {
String theChromeDriverBinary = System.getenv("CHROMEDRIVER_BINARY");
if (theChromeDriverBinary == null || theChromeDriverBinary.isEmpty()) {
throw new RuntimeException("No chromedriver binary found! Please set CHROMEDRIVER_BINARY environment variable!");
}
ChromeDriverService.Builder theDriverService = new ChromeDriverService.Builder();
theDriverService = theDriverService.withVerbose(false);
theDriverService = theDriverService.usingDriverExecutable(new File(theChromeDriverBinary));
DRIVERSERVICE = theDriverService.build();
DRIVERSERVICE.start();
Runtime.getRuntime().addShutdownHook(new Thread(() -> DRIVERSERVICE.stop()));
}
}
项目:atmosphere-agent
文件:RealWrapDevice.java
/**
* Creates an wrapper of the given real {@link IDevice device}.
*
* @param deviceToWrap
* - device to be wrapped
* @param executor
* - an {@link ExecutorService} used for async tasks
* @param shellCommandExecutor
* - an executor of shell commands for the wrapped device
* @param serviceCommunicator
* - a communicator to the service component on the device
* @param automatorCommunicator
* - a communicator to the UI automator component on the device
* @param chromeDriverService
* - the service component of the ChromeDriver
* @param fileRecycler
* - responsible for removing obsolete files
* @param ftpFileTransferService
* - responsible for file transfers to the FTP server
* @throws NotPossibleForDeviceException
* - thrown when Cannot create real wrap device for an emulator.
*/
public RealWrapDevice(IDevice deviceToWrap,
ExecutorService executor,
BackgroundShellCommandExecutor shellCommandExecutor,
ServiceCommunicator serviceCommunicator,
UIAutomatorCommunicator automatorCommunicator,
ChromeDriverService chromeDriverService,
FileRecycler fileRecycler,
FtpFileTransferService ftpFileTransferService)
throws NotPossibleForDeviceException {
super(deviceToWrap,
executor,
shellCommandExecutor,
serviceCommunicator,
automatorCommunicator,
chromeDriverService,
fileRecycler,
ftpFileTransferService);
if (deviceToWrap.isEmulator()) {
throw new NotPossibleForDeviceException("Cannot create real wrap device for an emulator.");
}
}
项目:atmosphere-agent
文件:AbstractWrapDeviceTest.java
public FakeWrapDevice(IDevice deviceToWrap,
ExecutorService executor,
BackgroundShellCommandExecutor shellCommandExecutor,
ServiceCommunicator serviceCommunicator,
UIAutomatorCommunicator automatorCommunicator,
ChromeDriverService chromeDriverService,
FileRecycler fileRecycler,
FtpFileTransferService ftpFileTransferService) {
super(deviceToWrap,
executor,
shellCommandExecutor,
serviceCommunicator,
automatorCommunicator,
chromeDriverService,
fileRecycler,
null);
}
项目:qaf
文件:ChromeDriverHelper.java
private synchronized void createAndStartService() {
if ((service != null) && service.isRunning()) {
return;
}
File driverFile = new File(ApplicationProperties.CHROME_DRIVER_PATH.getStringVal("./chromedriver.exe"));
if (!driverFile.exists()) {
logger.error("Please set webdriver.chrome.driver property properly.");
throw new AutomationError("Driver file not exist.");
}
try {
System.setProperty("webdriver.chrome.driver", driverFile.getCanonicalPath());
service = ChromeDriverService.createDefaultService();
service.start();
} catch (IOException e) {
logger.error("Unable to start Chrome driver", e);
throw new AutomationError("Unable to start Chrome Driver Service ", e);
}
}
项目:kc-rice
文件:WebDriverUtils.java
/**
* <p>
* <a href="http://code.google.com/p/chromedriver/downloads/list">ChromeDriver downloads</a>, {@see #REMOTE_PUBLIC_CHROME},
* {@see #WEBDRIVER_CHROME_DRIVER}, and {@see #HUB_DRIVER_PROPERTY}
* </p>
*
* @return chromeDriverService
*/
public static ChromeDriverService chromeDriverCreateCheck() {
String driverParam = System.getProperty(HUB_DRIVER_PROPERTY);
// TODO can the saucelabs driver stuff be leveraged here?
if (driverParam != null && "chrome".equals(driverParam.toLowerCase())) {
if (System.getProperty(WEBDRIVER_CHROME_DRIVER) == null) {
if (System.getProperty(REMOTE_PUBLIC_CHROME) != null) {
System.setProperty(WEBDRIVER_CHROME_DRIVER, System.getProperty(REMOTE_PUBLIC_CHROME));
}
}
try {
ChromeDriverService chromeDriverService = new ChromeDriverService.Builder()
.usingDriverExecutable(new File(System.getProperty(WEBDRIVER_CHROME_DRIVER)))
.usingAnyFreePort()
.build();
return chromeDriverService;
} catch (Throwable t) {
throw new RuntimeException("Exception starting chrome driver service, is chromedriver ( http://code.google.com/p/chromedriver/downloads/list ) installed? You can include the path to it using -Dremote.public.chrome", t) ;
}
}
return null;
}
项目:de.lgohlke.selenium-webdriver
文件:ChromeDriverServiceFactory.java
public ChromeDriverService createService(String... args) {
Preconditions.checkArgument(args.length % 2 == 0, "arguments should be pairs");
Map<String, String> environment = new HashMap<>();
for (int i = 1; i < args.length; i += 2) {
environment.put(args[i - 1], args[i]);
}
handleDISPLAYonLinux(environment);
ChromeDriverService service = new Builder()
.usingDriverExecutable(locationStrategy.findExecutable())
.withVerbose(log.isDebugEnabled())
.withEnvironment(environment)
.usingAnyFreePort()
.build();
LoggingOutputStream loggingOutputStream = new LoggingOutputStream(log, LogLevel.INFO);
service.sendOutputTo(loggingOutputStream);
return service;
}
项目:de.lgohlke.selenium-webdriver
文件:ChromeDriverServiceFactoryIT.java
@Test
public void startAndStop() throws IOException {
ChromeDriverService driverService = factory.createService();
try {
driverService.start();
WebDriver webDriver = factory.createWebDriver(driverService);
String url = "http://localhost:" + httpServer.getAddress()
.getPort() + "/webdriverTest";
webDriver.get(url);
assertThat(webDriver.getCurrentUrl()).isEqualTo(url);
} finally {
driverService.stop();
}
}
项目:rice
文件:WebDriverUtils.java
/**
* <p>
* <a href="http://code.google.com/p/chromedriver/downloads/list">ChromeDriver downloads</a>, {@see #REMOTE_PUBLIC_CHROME},
* {@see #WEBDRIVER_CHROME_DRIVER}, and {@see #HUB_DRIVER_PROPERTY}
* </p>
*
* @return chromeDriverService
*/
public static ChromeDriverService chromeDriverCreateCheck() {
String driverParam = System.getProperty(HUB_DRIVER_PROPERTY);
// TODO can the saucelabs driver stuff be leveraged here?
if (driverParam != null && "chrome".equals(driverParam.toLowerCase())) {
if (System.getProperty(WEBDRIVER_CHROME_DRIVER) == null) {
if (System.getProperty(REMOTE_PUBLIC_CHROME) != null) {
System.setProperty(WEBDRIVER_CHROME_DRIVER, System.getProperty(REMOTE_PUBLIC_CHROME));
}
}
try {
ChromeDriverService chromeDriverService = new ChromeDriverService.Builder()
.usingDriverExecutable(new File(System.getProperty(WEBDRIVER_CHROME_DRIVER)))
.usingAnyFreePort()
.build();
return chromeDriverService;
} catch (Throwable t) {
throw new RuntimeException("Exception starting chrome driver service, is chromedriver ( http://code.google.com/p/chromedriver/downloads/list ) installed? You can include the path to it using -Dremote.public.chrome", t) ;
}
}
return null;
}
项目:jfunk
文件:ConfigBrowser.java
@Subscribe
public void configureBrowser(final BeforeWebDriverCreationEvent event) {
switch (browser) {
case "firefox": {
// configure Firefox
}
case "chrome": {
setPathToDriverIfExistsAndIsExecutable(relativePathToChromeDriver, ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY);
// configure Chrome
break;
}
case "ie": {
setPathToDriverIfExistsAndIsExecutable(relativePathToIeDriver, InternetExplorerDriverService.IE_DRIVER_EXE_PROPERTY);
// configure InternetExplorer
break;
}
default: {
throw new RuntimeException(String.format("Please configure one of the supported browsers in %s", JFunkConstants.SCRIPT_PROPERTIES));
}
}
}
项目:kuali_rice
文件:WebDriverUtil.java
/**
* @link http://code.google.com/p/chromedriver/downloads/list
* @link #REMOTE_PUBLIC_CHROME
* @link #WEBDRIVER_CHROME_DRIVER
* @link ITUtil#HUB_DRIVER_PROPERTY
* @return chromeDriverService
*/
public static ChromeDriverService chromeDriverCreateCheck() {
String driverParam = System.getProperty(ITUtil.HUB_DRIVER_PROPERTY);
// TODO can the saucelabs driver stuff be leveraged here?
if (driverParam != null && "chrome".equals(driverParam.toLowerCase())) {
if (System.getProperty(WEBDRIVER_CHROME_DRIVER) == null) {
if (System.getProperty(REMOTE_PUBLIC_CHROME) != null) {
System.setProperty(WEBDRIVER_CHROME_DRIVER, System.getProperty(REMOTE_PUBLIC_CHROME));
}
}
try {
ChromeDriverService chromeDriverService = new ChromeDriverService.Builder()
.usingDriverExecutable(new File(System.getProperty(WEBDRIVER_CHROME_DRIVER)))
.usingAnyFreePort()
.build();
return chromeDriverService;
} catch (Throwable t) {
throw new RuntimeException("Exception starting chrome driver service, is chromedriver ( http://code.google.com/p/chromedriver/downloads/list ) installed? You can include the path to it using -Dremote.public.chrome", t) ;
}
}
return null;
}
项目:camunda-bpm-platform
文件:AbstractWebappUiIntegrationTest.java
@BeforeClass
public static void createDriver() {
String chromeDriverExecutable = "chromedriver";
if (System.getProperty( "os.name" ).toLowerCase(Locale.US).indexOf("windows") > -1) {
chromeDriverExecutable += ".exe";
}
File chromeDriver = new File("target/chromedriver/" + chromeDriverExecutable);
if (!chromeDriver.exists()) {
throw new RuntimeException("chromedriver could not be located!");
}
ChromeDriverService chromeDriverService = new ChromeDriverService.Builder()
.withVerbose(true)
.usingAnyFreePort()
.usingDriverExecutable(chromeDriver)
.build();
driver = new ChromeDriver(chromeDriverService);
}
项目:jspider
文件:WebDriverFactory.java
public ChromeDriverService.Builder createChromeDriverServiceBuilder(SiteConfig siteConfig, DriverConfig driverConfig, File driverFile) {
ChromeDriverService.Builder serviceBuilder = new ChromeDriverService.Builder();
serviceBuilder.usingDriverExecutable(driverFile);
serviceBuilder.usingAnyFreePort();
// serviceBuilder.usingPort(int)
// serviceBuilder.withVerbose(boolean);
// serviceBuilder.withLogFile(File)
// serviceBuilder.withEnvironment(Map<String, String>)
// serviceBuilder.withSilent(boolean)
// serviceBuilder.withWhitelistedIps(String)
return serviceBuilder;
}
项目:jspider
文件:WebDriverSpiderSample.java
public static void main(String[] args) {
//设置相应的驱动程序的位置
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, "F:\\selenium\\chromedriver.exe");
System.setProperty(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "F:\\selenium\\phantomjs.exe");
//任务执行线程池大小
int threadCount = 5;
SpiderConfig spiderConfig = SpiderConfig.create("baidu", threadCount)
.setEmptySleepMillis(1000)
.setExitWhenComplete(true);
SiteConfig siteConfig = SiteConfig.create()
.setMaxConnTotal(200)
.setMaxConnPerRoute(100);
//定义WebDriver池
WebDriverPool webDriverPool = new WebDriverPool(
new WebDriverFactory(),
new DefaultWebDriverChooser(DriverType.CHROME),
threadCount);
//使用WebDriverDownloader请求任务下载器
Downloader downloader = new WebDriverDownloader(webDriverPool);
Spider spider = Spider.create(spiderConfig, siteConfig, new BaiduPageProcessor())
.setDownloader(downloader) //设置请求任务下载器
.setPipeline(new BaiduPipeline())
.addStartRequests("https://www.baidu.com/s?wd=https");
//监控
SpiderMonitor.register(spider);
//启动
spider.start();
}
项目:Learning-Spring-Boot-2.0-Second-Edition
文件:WebDriverAutoConfiguration.java
@Bean(destroyMethod = "stop")
@Lazy
public ChromeDriverService chromeDriverService() {
System.setProperty("webdriver.chrome.driver",
"ext/chromedriver");
return createDefaultService();
}
项目:NoraUi
文件:DriverFactory.java
/**
* Generates a chrome webdriver.
*
* @param headlessMode
* Enable headless mode ?
* @return
* A chrome webdriver
* @throws TechnicalException
* if an error occured when Webdriver setExecutable to true.
*/
private WebDriver generateGoogleChromeDriver(boolean headlessMode) throws TechnicalException {
final String pathWebdriver = DriverFactory.getPath(Driver.CHROME);
if (!new File(pathWebdriver).setExecutable(true)) {
throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_WEBDRIVER_SET_EXECUTABLE));
}
logger.info("Generating Chrome driver ({}) ...", pathWebdriver);
System.setProperty(Driver.CHROME.getDriverName(), pathWebdriver);
final ChromeOptions chromeOptions = new ChromeOptions();
final DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
setLoggingLevel(capabilities);
if (Context.isHeadless()) {
chromeOptions.addArguments("--headless");
}
// Proxy configuration
if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
capabilities.setCapability(CapabilityType.PROXY, Context.getProxy());
}
setChromeOptions(capabilities, chromeOptions);
String withWhitelistedIps = Context.getWebdriversProperties("withWhitelistedIps");
if (withWhitelistedIps != null && !"".equals(withWhitelistedIps)) {
ChromeDriverService service = new ChromeDriverService.Builder().withWhitelistedIps(withWhitelistedIps).withVerbose(false).build();
return new ChromeDriver(service, capabilities);
} else {
return new ChromeDriver(capabilities);
}
}
项目:moviediary
文件:Utils.java
public static ChromeDriverService createDriverService() throws IOException {
ChromeDriverService service = new ChromeDriverService.Builder()
.usingDriverExecutable(new File(System.getProperty("user.dir") + separator + "misc" +
separator + "chromedriver.exe"))
.usingAnyFreePort()
.build();
service.start();
return service;
}
项目:PiYouTube
文件:PiYouTube.java
public void launchChromeDriver()
{
System.setProperty("webdriver.chrome.driver", this.config.getString("driver"));
ChromeOptions chromeParams = new ChromeOptions();
JSONArray options = this.config.getJSONArray("chromeParams");
if(options != null)
{
for(int i = 0; i < options.length(); i++)
{
chromeParams.addArguments(options.getString(i));
}
}
if(this.config.optString("chrome", null) != null)
{
chromeParams.setBinary(this.config.getString("chrome"));
}
try
{
if(! Util.isUnix())
{
this.chromeDriver = new ChromeDriver(chromeParams);
}
else
{
this.chromeDriver = new ChromeDriver(new ChromeDriverService.Builder().withEnvironment(ImmutableMap.of("DISPLAY",":0.0")).build(), chromeParams);
}
}
catch(Exception e)
{
System.out.println("Error loading chromedriver. Are you sure the correct path is set in config.json?");
e.printStackTrace();
System.exit(0);
}
}
项目:bromium
文件:ChromeDriverServiceSupplierTest.java
@Test
public void canStartDriverService() throws Exception {
String pathToDriver = "chromedriver";
String screenToUse = ":1";
ChromeDriverService.Builder builder = mock(ChromeDriverService.Builder.class, RETURNS_MOCKS);
ChromeDriverServiceSupplier chromeDriverServiceSupplier = new ChromeDriverServiceSupplier();
whenNew(ChromeDriverService.Builder.class).withNoArguments().thenReturn(builder);
chromeDriverServiceSupplier.getDriverService(pathToDriver, screenToUse);
verify(builder).usingDriverExecutable(eq(new File(pathToDriver)));
}
项目:bromium
文件:ChromeDriverSupplierTest.java
@Test
public void callsTheCorrectConstructor() throws Exception {
ChromeDriverService chromeDriverService = mock(ChromeDriverService.class);
DesiredCapabilities desiredCapabilities = mock(DesiredCapabilities.class);
ChromeDriver expected = mock(ChromeDriver.class);
whenNew(ChromeDriver.class).withArguments(chromeDriverService, desiredCapabilities).thenReturn(expected);
ChromeDriverSupplier chromeDriverSupplier = new ChromeDriverSupplier();
WebDriver actual = chromeDriverSupplier.get(chromeDriverService, desiredCapabilities);
assertEquals(expected, actual);
}
项目:hippo
文件:WebDriverServiceProvider.java
/**
* Starts WebDriver service.
*
* For perfomance reasons, this method should be called once before the entire testing session rather than
* before each test.
*/
public void initialise() {
chromeDriverService = new ChromeDriverService.Builder()
.usingAnyFreePort()
.usingDriverExecutable(getChromedriverFileLocation())
.build();
try {
chromeDriverService.start();
} catch (final IOException e) {
throw new UncheckedIOException(e);
}
}
项目:hippo
文件:WebDriverServiceProvider.java
private ChromeDriverService getChromeDriverService() {
if (chromeDriverService == null) {
throw new IllegalStateException(
"WebDriverService hasn't been initialised, yet. Have you forgotten to call 'initialise()' first?");
}
return chromeDriverService;
}
项目:argument-reasoning-comprehension-task
文件:DebateFetcher.java
public DebateFetcher(String chromeDriverFile)
throws IOException
{
service = new ChromeDriverService.Builder()
.usingDriverExecutable(
new File(chromeDriverFile))
.usingAnyFreePort()
.withEnvironment(ImmutableMap.of("DISPLAY", ":20")).build();
service.start();
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
driver = new RemoteWebDriver(service.getUrl(), capabilities);
}
项目:delay-repay-bot
文件:PhantomJSTest.java
public static DesiredCapabilities getChromeCapabilities() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setJavascriptEnabled(true);
capabilities.setCapability("acceptSslCerts", true);
capabilities.setCapability("takesScreenshot", true);
capabilities.setCapability(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, asList("--ignore-ssl-errors=true"));
LoggingPreferences loggingPreferences = new LoggingPreferences();
loggingPreferences.enable(LogType.BROWSER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, loggingPreferences);
return capabilities;
}
项目:atmosphere-agent
文件:AbstractWrapDevice.java
/**
* Creates an abstract wrapper of the given {@link IDevice device}.
*
* @param deviceToWrap
* - device to be wrapped
* @param executor
* - an {@link ExecutorService} used for async tasks
* @param shellCommandExecutor
* - an executor of shell commands for the wrapped device
* @param serviceCommunicator
* - a communicator to the service component on the device
* @param automatorCommunicator
* - a communicator to the UI automator component on the device
* @param chromeDriverService
* - the service component of the ChromeDriver
* @param fileRecycler
* - responsible for removing obsolete files
* @param ftpFileTransferService
* - responsible for file transfers to the FTP server
*/
public AbstractWrapDevice(IDevice deviceToWrap,
ExecutorService executor,
BackgroundShellCommandExecutor shellCommandExecutor,
ServiceCommunicator serviceCommunicator,
UIAutomatorCommunicator automatorCommunicator,
ChromeDriverService chromeDriverService,
FileRecycler fileRecycler,
FtpFileTransferService ftpFileTransferService) {
// TODO: Use a dependency injection mechanism here.
this.wrappedDevice = deviceToWrap;
this.executor = executor;
this.shellCommandExecutor = shellCommandExecutor;
this.serviceCommunicator = serviceCommunicator;
this.automatorCommunicator = automatorCommunicator;
this.fileRecycler = fileRecycler;
this.logcatBuffer = new Buffer<String, Pair<Integer, String>>();
this.ftpFileTransferService = ftpFileTransferService;
transferService = new FileTransferService(wrappedDevice);
apkInstaller = new ApkInstaller(wrappedDevice);
imeManager = new ImeManager(shellCommandExecutor);
pullFileCompletionService = new ExecutorCompletionService<>(executor);
webElementManager = new WebElementManager(chromeDriverService, deviceToWrap.getSerialNumber());
deviceInformation = getDeviceInformation();
try {
setupDeviceEntities(deviceInformation);
} catch (UnresolvedEntityTypeException e) {
LOGGER.warn(e.getMessage());
}
}
项目:easytest
文件:DriverFactory.java
private static void initializeChromeVariables() {
final URL resource = DriverFactory.class.getClassLoader().getResource("drivers");
final String chromeExecutableFolder = resource.getPath() + File.separator + environment();
if (environment().equals("windows")) {
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, chromeExecutableFolder + File.separator + "chromedriver.exe");
}
else {
final File chromeExecutable = new File(chromeExecutableFolder, "chromedriver");
chromeExecutable.setExecutable(true);
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, chromeExecutable.getAbsolutePath());
}
}
项目:domui
文件:WebDriverFactory.java
private static WebDriver allocateChromeInstance(BrowserModel model, Locale lang) throws IOException {
DesiredCapabilities dc;
switch(model) {
default:
throw new IllegalStateException("Unsupported browser type " + model.getCode() + " for local execution");
case CHROME:
dc = getChromeCapabilities(lang);
break;
case CHROME_HEADLESS:
dc = getChromeHeadlessCapabilities(lang);
break;
}
TestProperties tp = TUtilTestProperties.getTestProperties();
String chromeBinariesLocation = tp.getProperty("webdriver.chrome.driver", "/usr/bin/google-chrome");
System.setProperty("webdriver.chromedriver", chromeBinariesLocation);
dc.setCapability("chrome.binary", chromeBinariesLocation);
//-- Set the XDG_CONFIG_HOME envvar; this is used by fontconfig as one of its locations
File dir = createFontConfigFile();
Map<String, String> env = new HashMap<>();
env.put("XDG_CONFIG_HOME", dir.getParentFile().getAbsolutePath());
Builder builder = new Builder();
builder.usingAnyFreePort();
builder.withEnvironment(env);
ChromeDriverService service = builder.build();
MyChromeDriver chromeDriver = new MyChromeDriver(service, dc);
chromeDriver.manage().window().setSize(new Dimension(1280, 1024));
String browserName = chromeDriver.getCapabilities().getBrowserName();
String version = chromeDriver.getCapabilities().getVersion();
System.out.println("wd: allocated " + browserName + " " + version);
return chromeDriver;
}
项目:domui
文件:MyChromeDriver.java
public MyChromeDriver(ChromeDriverService service, Capabilities capabilities) {
super(new MyChromeDriverCommandExecutor(service), capabilities);
this.locationContext = new RemoteLocationContext(this.getExecuteMethod());
this.webStorage = new RemoteWebStorage(this.getExecuteMethod());
this.touchScreen = new RemoteTouchScreen(this.getExecuteMethod());
this.networkConnection = new RemoteNetworkConnection(this.getExecuteMethod());
}
项目:de.lgohlke.selenium-webdriver
文件:ChromeDriverServiceFactoryTest.java
@Test
public void environmentVariableShouldBePropagated() throws NoSuchFieldException, IllegalAccessException {
ChromeDriverService service = serviceFactory.createService("DISPLAY", "X");
Map<String, String> env = getEnvFromDriverService(service);
assertThat(env).containsEntry("DISPLAY", "X");
}
项目:de.lgohlke.selenium-webdriver
文件:ChromeDriverServiceFactoryTest.java
@Test
public void onLinux_shouldSetDisplayToZEROIfUnset() throws NoSuchFieldException, IllegalAccessException {
environmentVariables.set("DISPLAY",null);
environmentVariables.set("os.name", "Linux");
ChromeDriverService service = serviceFactory.createService();
Map<String, String> env = getEnvFromDriverService(service);
assertThat(env).containsEntry("DISPLAY", ":0");
}
项目:de.lgohlke.selenium-webdriver
文件:ChromeDriverServiceFactoryTest.java
@Test
public void onLinux_shouldUseDisplayFromEnvironment() throws NoSuchFieldException, IllegalAccessException {
environmentVariables.set("DISPLAY", "Y");
environmentVariables.set("os.name", "Linux");
ChromeDriverService service = serviceFactory.createService();
Map<String, String> env = getEnvFromDriverService(service);
assertThat(env).containsEntry("DISPLAY", "Y");
}
项目:dawg
文件:BrowserServiceManager.java
/**
* 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;
}
项目:FuncaoWeb
文件:DriverChrome.java
private WebDriver getChromeConfigurado(String proxy) {
DesiredCapabilities capabilities = new DesiredCapabilities();
ArrayList<String> switches = new ArrayList<String>();
//Habilitar todas as extens�es, mas o problema que n�o carrega o proxy correto
//switches.add("--user-data-dir="+System.getProperty("user.home")+"\\AppData\\Local\\Google\\Chrome\\User Data");
//switches.add("--load-extension="+System.getProperty("user.home")+"\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Extensions\\chklaanhfefbnpoihckbnefhakgolnmc\\0.0.32_0");
if (!(proxy.equals(""))) {
System.out.println("Passou aqui");
switches.add("--proxy-server=" + "http://" + proxy);
} else {
System.out.println("Voc� n�o est� usando proxy!");
}
switches.add("--ignore-certificate-errors");
switches.add("--start-maximized");
//switches.add("--disable-extensions"); Desabilitar todas as extens�es.
capabilities.setBrowserName("chrome");
capabilities.setJavascriptEnabled(true);
capabilities.setCapability("chrome.switches", switches);
chromeService = new ChromeDriverService.Builder()
.usingDriverExecutable(new File(InterNavegador.PATH_CHROME))
.usingAnyFreePort().build();
try {
chromeService.start();
} catch (IOException e) {
System.out.println(e);
}
return new RemoteWebDriver(chromeService.getUrl(), capabilities);
}
项目:seauto
文件:AbstractConfigurableDriverProvider.java
protected WebDriver getChromeWebDriver()
{
String pathToDriverBin = getOsSpecificBinaryPathFromProp(CHROME_DRIVER_BIN_PROP, "chromedriver");
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, pathToDriverBin);
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
return new ChromeDriver(capabilities);
}
项目:minium
文件:ChromeDriverServiceProperties.java
@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();
}
项目:webdriver-runner
文件:LazyAutoStoppingChromeDriverService.java
protected ChromeDriverService start() throws IOException {
if (service != null)
throw new IllegalStateException();
ChromeDriverService newService = ChromeDriverService.createDefaultService();
newService.start();
Runtime.getRuntime().addShutdownHook(getNewShutdownHookThread());
return newService;
}
项目:jspider
文件:WebDriverFactory.java
public WebDriverEx createChromeWebDriver(SiteConfig siteConfig, DriverConfig driverConfig) throws IOException {
File driverFile = createDriverFile(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY);
DesiredCapabilities desiredCapabilities = createChromeDesiredCapabilities(siteConfig, driverConfig);
ChromeDriverService driverService = createChromeDriverService(siteConfig, driverConfig, driverFile);
return createWebDriver(driverService, desiredCapabilities, siteConfig, driverConfig);
}
项目:jspider
文件:WebDriverFactory.java
public ChromeDriverService createChromeDriverService(SiteConfig siteConfig, DriverConfig driverConfig, File driverFile) {
return createChromeDriverServiceBuilder(siteConfig, driverConfig, driverFile).build();
}
项目:Learning-Spring-Boot-2.0-Second-Edition
文件:ChromeDriverFactory.java
public ChromeDriverFactory(ChromeDriverService chromeDriverService,
WebDriverConfigurationProperties properties) {
this.chromeDriverService = chromeDriverService;
this.properties = properties;
}
项目:bromium
文件:ChromeDriverServiceSupplier.java
@Override
protected DriverService.Builder getBuilder() {
return new ChromeDriverService.Builder();
}