本文整理汇总了Java中com.machinepublishers.jbrowserdriver.Settings类的典型用法代码示例。如果您正苦于以下问题:Java Settings类的具体用法?Java Settings怎么用?Java Settings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Settings类属于com.machinepublishers.jbrowserdriver包,在下文中一共展示了Settings类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Adidas
import com.machinepublishers.jbrowserdriver.Settings; //导入依赖的package包/类
public Adidas(ProxyObject proxy, CredentialObject credentials, String url, boolean splash, boolean manual, double[] sizes) {
super();
Builder builder = Settings.builder();
if(proxy != null) {
builder.proxy(new ProxyConfig(Type.HTTP, proxy.getAddress(), proxy.getPort()));
//String server = proxy.getAddress() + ":" + proxy.getPort();
//capability.setCapability(CapabilityType.PROXY, new Proxy().setHttpProxy(server).setFtpProxy(server).setSslProxy(server));
}
builder.logsMax(0);
builder.loggerLevel(Level.OFF);
builder.userAgent(UserAgent.CHROME);
driver = new JBrowserDriver(builder.build());
driver.manage().timeouts().setScriptTimeout(30L, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(30L, TimeUnit.SECONDS);
this.proxy = proxy;
this.url = url;
this.splash = splash;
this.manual = manual;
this.sizes = sizes;
carted = false;
}
示例2: before
import com.machinepublishers.jbrowserdriver.Settings; //导入依赖的package包/类
@GwtIncompatible
@Before
public void before() {
// for correct stacktrace decoding, we need the debug info.
boolean debug = true;
// Convert to javascript
VertxUI.with(this.getClass(), null, debug, true);
// Start the headless browser
jBrowser = new JBrowserDriver(Settings.builder().logJavascript(true).build());
jBrowser.get("file:///" + new File(VertxUI.getTargetFolder(debug) + "/index.html").getAbsolutePath());
}
示例3: getDriver
import com.machinepublishers.jbrowserdriver.Settings; //导入依赖的package包/类
@Override
protected WebDriver getDriver() throws Exception
{
Capabilities capabilities = Settings.builder()
.headless(false)
.saveAttachments(true)
.screen(new Dimension(1200, 700))
.ssl("trustanything")
.timezone(Timezone.ASIA_TOKYO)
.buildCapabilities();
return new JBrowserDriver(capabilities);
}
示例4: runJava
import com.machinepublishers.jbrowserdriver.Settings; //导入依赖的package包/类
private CompletableFuture<?> runJava(String javaSource) {
return MoreFutures.submitAsync(new Callable</*@Nullable*/ Void>() {
@Override
public @Nullable Void call() throws Exception {
Class<?> syntheticUserTestClass = Compilations.compile(javaSource);
// validation for default constructor and test method occurs on save
Constructor<?> defaultConstructor = syntheticUserTestClass.getConstructor();
Method method = syntheticUserTestClass.getMethod("test", WebDriver.class);
Settings.Builder settings = Settings.builder()
.requestHeaders(REQUEST_HEADERS)
.userAgent(userAgent);
HttpProxyConfig httpProxyConfig = configRepository.getHttpProxyConfig();
if (!httpProxyConfig.host().isEmpty()) {
int proxyPort = MoreObjects.firstNonNull(httpProxyConfig.port(), 80);
settings.proxy(new ProxyConfig(ProxyConfig.Type.HTTP, httpProxyConfig.host(),
proxyPort, httpProxyConfig.username(), httpProxyConfig.password()));
}
JBrowserDriver driver = new JBrowserDriver(settings.build());
try {
method.invoke(defaultConstructor.newInstance(), driver);
} finally {
driver.quit();
}
return null;
}
}, syntheticUserTestExecutor);
}