本文整理汇总了Java中io.github.bonigarcia.wdm.FirefoxDriverManager类的典型用法代码示例。如果您正苦于以下问题:Java FirefoxDriverManager类的具体用法?Java FirefoxDriverManager怎么用?Java FirefoxDriverManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FirefoxDriverManager类属于io.github.bonigarcia.wdm包,在下文中一共展示了FirefoxDriverManager类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDriver
import io.github.bonigarcia.wdm.FirefoxDriverManager; //导入依赖的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.FirefoxDriverManager; //导入依赖的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: browserInit
import io.github.bonigarcia.wdm.FirefoxDriverManager; //导入依赖的package包/类
/**
* Starts firefox through selenium to retrieve
* cookie instance and process initialization.
*
* @param driverSupplier Driver supplier to use.
* @param contest Contest identifier to use.
* @return <tt>true</tt> if the init command was correctly executed, <tt>false</tt> otherwise.
*/
private static CommandStatus browserInit(final Supplier<WebDriver> driverSupplier, final String contest) {
out.println("[Initialization] Web browser will open, please authenticate to your Google account with it.");
FirefoxDriverManager.getInstance().setup();
final SeleniumCookieSupplier supplier = new SeleniumCookieSupplier(Request.getHostname() + "/codejam", FirefoxDriver::new);
try {
final String cookie = supplier.get();
if (cookie == null) {
err.println("-> Retrieved cookie instance is null, abort.");
}
else {
return init(cookie, contest);
}
}
catch (final IOException | UnreachableBrowserException | GeneralSecurityException e) {
err.println("-> An error occurs while creating CodeJamSession");
if (Application.isVerbose()) {
e.printStackTrace();
}
}
return CommandStatus.FAILED;
}
示例4: Setup
import io.github.bonigarcia.wdm.FirefoxDriverManager; //导入依赖的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();
}
}
示例5: gecko
import io.github.bonigarcia.wdm.FirefoxDriverManager; //导入依赖的package包/类
private WebDriver gecko(DesiredCapabilities customDesiredCapabilities) {
FirefoxDriverManager.getInstance().setup();
DesiredCapabilities desiredCapabilities = getGeckoDesiredCapabilities();
if (!customDesiredCapabilities.asMap().isEmpty()) {
desiredCapabilities.merge(customDesiredCapabilities);
}
return new FirefoxDriver(desiredCapabilities);
}
示例6: downloadDriver
import io.github.bonigarcia.wdm.FirefoxDriverManager; //导入依赖的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());
}
}
示例7: createFirefoxWebDriver
import io.github.bonigarcia.wdm.FirefoxDriverManager; //导入依赖的package包/类
private static WebDriver createFirefoxWebDriver() {
if (!mInitializedWebDrivers.contains(WebDriverType.FIREFOX)) {
FirefoxDriverManager.getInstance().version("0.14.0").setup();
mInitializedWebDrivers.add(WebDriverType.FIREFOX);
}
// final DesiredCapabilities capabilities = DesiredCapabilities.firefox();
// capabilities.setCapability("marionette", true);
// final WebDriver selenium = new FirefoxDriver(capabilities);
final WebDriver selenium = new FirefoxDriver();
return selenium;
}
示例8: createDriver
import io.github.bonigarcia.wdm.FirefoxDriverManager; //导入依赖的package包/类
@Override
public WebDriver createDriver(Capabilities capabilities) {
String driverVersion = (String) capabilities.getCapability(CAPABILITY_DRIVER_VERSION);
FirefoxDriverManager.getInstance().version(driverVersion).setup();
return new FirefoxDriver((FirefoxOptions) capabilities);
}
示例9: beforeTest
import io.github.bonigarcia.wdm.FirefoxDriverManager; //导入依赖的package包/类
@BeforeClass(alwaysRun = true)
public void beforeTest() {
FirefoxDriverManager.getInstance().setup();
}
示例10: setupClass
import io.github.bonigarcia.wdm.FirefoxDriverManager; //导入依赖的package包/类
@BeforeClass
public static void setupClass() {
ChromeDriverManager.getInstance().setup();
FirefoxDriverManager.getInstance().setup();
}
示例11: setupClass
import io.github.bonigarcia.wdm.FirefoxDriverManager; //导入依赖的package包/类
@BeforeClass
public static void setupClass() {
FirefoxDriverManager.getInstance().setup();
}
示例12: setup
import io.github.bonigarcia.wdm.FirefoxDriverManager; //导入依赖的package包/类
@Before
public void setup() {
browserManager = FirefoxDriverManager.getInstance();
specificVersions = new String[] { "0.8.0", "0.19.1" };
}