本文整理汇总了Java中org.openqa.selenium.chrome.ChromeDriverService.Builder类的典型用法代码示例。如果您正苦于以下问题:Java Builder类的具体用法?Java Builder怎么用?Java Builder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Builder类属于org.openqa.selenium.chrome.ChromeDriverService包,在下文中一共展示了Builder类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createService
import org.openqa.selenium.chrome.ChromeDriverService.Builder; //导入依赖的package包/类
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;
}
示例2: allocateChromeInstance
import org.openqa.selenium.chrome.ChromeDriverService.Builder; //导入依赖的package包/类
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;
}
示例3: createDriverService
import org.openqa.selenium.chrome.ChromeDriverService.Builder; //导入依赖的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();
}