本文整理汇总了Java中io.github.bonigarcia.wdm.ChromeDriverManager类的典型用法代码示例。如果您正苦于以下问题:Java ChromeDriverManager类的具体用法?Java ChromeDriverManager怎么用?Java ChromeDriverManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChromeDriverManager类属于io.github.bonigarcia.wdm包,在下文中一共展示了ChromeDriverManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDriver
import io.github.bonigarcia.wdm.ChromeDriverManager; //导入依赖的package包/类
public static WebDriver getDriver() {
String browser = System.getenv("BROWSER");
if (browser == null) {
ChromeDriverManager.getInstance().setup();
return new ChromeDriver();
}
switch (browser)
{
case "IE":
InternetExplorerDriverManager.getInstance().setup();
return new InternetExplorerDriver();
case "FIREFOX":
FirefoxDriverManager.getInstance().setup();
return new FirefoxDriver();
default:
ChromeDriverManager.getInstance().setup();
return new ChromeDriver();
}
}
示例2: setup
import io.github.bonigarcia.wdm.ChromeDriverManager; //导入依赖的package包/类
@BeforeAll
static void setup() throws Exception {
// Start hub
GridLauncherV3.main(new String[] { "-role", "hub", "-port", "4444" });
// Register Chrome in hub
ChromeDriverManager.getInstance().setup();
GridLauncherV3.main(new String[] { "-role", "node", "-hub",
"http://localhost:4444/grid/register", "-browser",
"browserName=chrome", "-port", "5555" });
// Register Firefox in hub
FirefoxDriverManager.getInstance().setup();
GridLauncherV3.main(new String[] { "-role", "node", "-hub",
"http://localhost:4444/grid/register", "-browser",
"browserName=firefox", "-port", "5556" });
}
示例3: Setup
import io.github.bonigarcia.wdm.ChromeDriverManager; //导入依赖的package包/类
@BeforeSuite
public void Setup() {
// Uses chrome driver by default
String browser = System.getenv("BROWSER");
if (browser == null) {
browser = DEFAULT;
}
if (browser.toLowerCase().equals(FIREFOX)) {
FirefoxDriverManager.getInstance().setup();
driver = new FirefoxDriver();
} else if (browser.toLowerCase().equals(IE)) {
InternetExplorerDriverManager.getInstance().setup();
driver = new InternetExplorerDriver();
} else {
ChromeDriverManager.getInstance().setup();
driver = new ChromeDriver();
}
}
示例4: testIgnoreVersions
import io.github.bonigarcia.wdm.ChromeDriverManager; //导入依赖的package包/类
@Test
public void testIgnoreVersions() {
String[] ignoredVersions = { "2.33", "2.32" };
ChromeDriverManager.getInstance().ignoreVersions(ignoredVersions)
.setup();
File binary = new File(
ChromeDriverManager.getInstance().getBinaryPath());
log.debug("Using binary {} (ignoring {})", binary,
Arrays.toString(ignoredVersions));
for (String version : ignoredVersions) {
assertThat(binary.getName(), not(containsString(version)));
}
}
示例5: chrome
import io.github.bonigarcia.wdm.ChromeDriverManager; //导入依赖的package包/类
private WebDriver chrome(Settings settings, DesiredCapabilities customDesiredCapabilities) {
ChromeDriverManager.getInstance().setup();
DesiredCapabilities desiredCapabilities = getChromeDesiredCapabilities(settings);
if (!customDesiredCapabilities.asMap().isEmpty()) {
desiredCapabilities.merge(customDesiredCapabilities);
}
return new ChromeDriver(desiredCapabilities);
}
示例6: beforeTest
import io.github.bonigarcia.wdm.ChromeDriverManager; //导入依赖的package包/类
@Before
public void beforeTest() throws IOException {
ChromeDriverManager.getInstance().setup();
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);
desiredCapabilities.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
driver = new ChromeDriver(desiredCapabilities);
accessibilitySniffer = new AccessibilitySniffer(driver);
}
示例7: testForceOs
import io.github.bonigarcia.wdm.ChromeDriverManager; //导入依赖的package包/类
@Test
public void testForceOs() {
ChromeDriverManager.getInstance().operativeSystem(operativeSystem)
.setup();
File binary = new File(
ChromeDriverManager.getInstance().getBinaryPath());
log.debug("OS {} - binary path {}", operativeSystem, binary);
assertTrue(binary.exists());
}
示例8: testRealEnvProxyToNotNull
import io.github.bonigarcia.wdm.ChromeDriverManager; //导入依赖的package包/类
@Test
public void testRealEnvProxyToNotNull() throws Exception {
WebDriverManager browserManager = ChromeDriverManager.getInstance();
setSystemGetEnvMock(PROXY_URL);
InetSocketAddress address = (InetSocketAddress) getProxy(browserManager)
.get().address();
assertThat(address.getHostName(), equalTo(PROXY_URL));
}
示例9: testMockedEnvProxy
import io.github.bonigarcia.wdm.ChromeDriverManager; //导入依赖的package包/类
@Test
public void testMockedEnvProxy() throws Exception {
for (String proxyTestString : PROXYS_TEST_STRINGS) {
setSystemGetEnvMock(proxyTestString);
log.info("Testing proxy {}", proxyTestString);
WebDriverManager browserManager = ChromeDriverManager.getInstance();
InetSocketAddress address = (InetSocketAddress) getProxy(
browserManager).get().address();
assertThat(address.getHostName(), equalTo(PROXY_URL));
}
}
示例10: testTaobao
import io.github.bonigarcia.wdm.ChromeDriverManager; //导入依赖的package包/类
@Test
public void testTaobao() throws Exception {
setProperty("wdm.chromeDriverMirrorUrl",
"http://npm.taobao.org/mirrors/chromedriver/2.33/");
ChromeDriverManager.getInstance().useMirror().setup();
File binary = new File(
ChromeDriverManager.getInstance().getBinaryPath());
assertTrue(binary.exists());
}
示例11: testMockProx
import io.github.bonigarcia.wdm.ChromeDriverManager; //导入依赖的package包/类
@Test
public void testMockProx() throws MalformedURLException {
ChromeDriverManager.getInstance().proxy("localhost:" + proxyPort)
.proxyUser("").proxyPass("")
.driverRepositoryUrl(
new URL("https://chromedriver.storage.googleapis.com/"))
.setup();
File binary = new File(
ChromeDriverManager.getInstance().getBinaryPath());
assertTrue(binary.exists());
}
示例12: downloadDriver
import io.github.bonigarcia.wdm.ChromeDriverManager; //导入依赖的package包/类
public static void downloadDriver(DriverTypes driverType) {
BrowserManager bm = null;
try {
switch (driverType) {
case CHROME:
bm = ChromeDriverManager.getInstance(); break;
case FIREFOX:
bm = FirefoxDriverManager.getInstance(); break;
case IE:
bm = InternetExplorerDriverManager.getInstance(); break;
}
if (bm == null)
throw exception("Unknown driver: " + driverType);
switch (platform) {
case "32": bm = bm.arch32(); break;
case "64": bm = bm.arch64(); break;
}
if (hasVersion())
bm = bm.version(driverVersion);
bm.setup();
} catch (Exception ex) {
throw exception("Can't download latest driver for " + driverType
+ ". Exception " + ex.getMessage());
}
}
示例13: setupClass
import io.github.bonigarcia.wdm.ChromeDriverManager; //导入依赖的package包/类
@BeforeClass
public static void setupClass()
{
String szDriverType = System.getProperty( DRIVER_SYS_PROP );
if( StringUtils.isNotEmpty( szDriverType ) && szDriverType.equalsIgnoreCase( DriverType.CHROME.toString() ))
{
driverType = DriverType.CHROME;
ChromeDriverManager.getInstance().setup();
}
else
{
driverType = DriverType.FIREFOX;
MarionetteDriverManager.getInstance().setup();
}
}
示例14: createChromeWebDriver
import io.github.bonigarcia.wdm.ChromeDriverManager; //导入依赖的package包/类
private static WebDriver createChromeWebDriver() {
if (!mInitializedWebDrivers.contains(WebDriverType.CHROME)) {
ChromeDriverManager.getInstance().setup();
mInitializedWebDrivers.add(WebDriverType.CHROME);
}
final WebDriver selenium = new ChromeDriver();
return selenium;
}
示例15: BasePage
import io.github.bonigarcia.wdm.ChromeDriverManager; //导入依赖的package包/类
BasePage() {
ChromeDriverManager.getInstance().setup();
Configuration.browser = "chrome";
}