本文整理汇总了Java中org.openqa.selenium.firefox.FirefoxDriver类的典型用法代码示例。如果您正苦于以下问题:Java FirefoxDriver类的具体用法?Java FirefoxDriver怎么用?Java FirefoxDriver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FirefoxDriver类属于org.openqa.selenium.firefox包,在下文中一共展示了FirefoxDriver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFirefoxOptions
import org.openqa.selenium.firefox.FirefoxDriver; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("testClassProvider")
@SuppressWarnings("unchecked")
void testFirefoxOptions(Class<?> testClass) throws Exception {
Parameter parameter = testClass
.getMethod("webrtcTest", FirefoxDriver.class)
.getParameters()[0];
Optional<Object> testInstance = Optional.of(testClass.newInstance());
FirefoxOptions firefoxOptions = (FirefoxOptions) annotationsReader
.getOptions(parameter, testInstance);
Map<String, Map<String, Boolean>> options = (Map<String, Map<String, Boolean>>) firefoxOptions
.asMap().get(FIREFOX_OPTIONS);
assertTrue(options.get("prefs")
.get("media.navigator.permission.disabled"));
assertTrue(options.get("prefs").get("media.navigator.streams.fake"));
}
示例2: getDriver
import org.openqa.selenium.firefox.FirefoxDriver; //导入依赖的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();
}
}
示例3: selectLocalBrowser
import org.openqa.selenium.firefox.FirefoxDriver; //导入依赖的package包/类
public static WebDriver selectLocalBrowser() {
switch (browser) {
case Chrome:
return new ChromeDriver();
case Firefox:
return new FirefoxDriver();
case IE:
return new InternetExplorerDriver();
case Opera:
return new OperaDriver();
case Safari:
return new SafariDriver();
default:
throw new WebDriverException("No browser specified");
}
}
示例4: setUpTest
import org.openqa.selenium.firefox.FirefoxDriver; //导入依赖的package包/类
@Before
public void setUpTest(){
System.setProperty("webdriver.gecko.driver", "C:\\webdriver\\geckodriver-v0.11.1-win64\\geckodriver.exe");
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability("marionette", true);
driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://www.doqconsulting.com.br/#contact");
}
示例5: getFirefoxDriver
import org.openqa.selenium.firefox.FirefoxDriver; //导入依赖的package包/类
private static WebDriver getFirefoxDriver(){
/*
Need to have an updated Firefox, but also need
to download and put the geckodriver in your own home dir.
See:
https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
https://github.com/mozilla/geckodriver/releases
However, drivers for FireFox have been often unstable.
Therefore, I do recommend to use Chrome instead
*/
setupDriverExecutable("geckodriver", "webdriver.gecko.driver");
DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
desiredCapabilities.setCapability("marionette", true);
desiredCapabilities.setJavascriptEnabled(true);
return new FirefoxDriver(desiredCapabilities);
}
开发者ID:arcuri82,项目名称:testing_security_development_enterprise_systems,代码行数:22,代码来源:SeleniumTestBase.java
示例6: SeleniumExtension
import org.openqa.selenium.firefox.FirefoxDriver; //导入依赖的package包/类
public SeleniumExtension() {
handlerMap.put(ChromeDriver.class, ChromeDriverHandler.class);
handlerMap.put(FirefoxDriver.class, FirefoxDriverHandler.class);
handlerMap.put(EdgeDriver.class, EdgeDriverHandler.class);
handlerMap.put(OperaDriver.class, OperaDriverHandler.class);
handlerMap.put(SafariDriver.class, SafariDriverHandler.class);
handlerMap.put(RemoteWebDriver.class, RemoteDriverHandler.class);
handlerMap.put(AppiumDriver.class, AppiumDriverHandler.class);
handlerMap.put(List.class, ListDriverHandler.class);
handlerMap.put(PhantomJSDriver.class, OtherDriverHandler.class);
templateHandlerMap.put("chrome", ChromeDriver.class);
templateHandlerMap.put("firefox", FirefoxDriver.class);
templateHandlerMap.put("edge", EdgeDriver.class);
templateHandlerMap.put("opera", OperaDriver.class);
templateHandlerMap.put("safari", SafariDriver.class);
templateHandlerMap.put("appium", AppiumDriver.class);
templateHandlerMap.put("phantomjs", PhantomJSDriver.class);
templateHandlerMap.put("chrome-in-docker", RemoteWebDriver.class);
templateHandlerMap.put("firefox-in-docker", RemoteWebDriver.class);
templateHandlerMap.put("opera-in-docker", RemoteWebDriver.class);
}
示例7: resolve
import org.openqa.selenium.firefox.FirefoxDriver; //导入依赖的package包/类
@Override
public void resolve() {
try {
Optional<Object> testInstance = context.getTestInstance();
Optional<Capabilities> capabilities = annotationsReader
.getCapabilities(parameter, testInstance);
FirefoxOptions firefoxOptions = (FirefoxOptions) getOptions(
parameter, testInstance);
if (capabilities.isPresent()) {
firefoxOptions.merge(capabilities.get());
}
object = new FirefoxDriver(firefoxOptions);
} catch (Exception e) {
handleException(e);
}
}
示例8: getDriverUsingSwitch
import org.openqa.selenium.firefox.FirefoxDriver; //导入依赖的package包/类
public static WebDriver getDriverUsingSwitch() {
final String browser = System.getProperty("browser");
if (browser == null || browser.isEmpty()) {
throw new IllegalStateException("'browser' property is missing!");
}
switch (browser) {
case CHROME:
return new ChromeDriver();
case FIREFOX:
return new FirefoxDriver();
default:
throw new IllegalArgumentException(browser + " browser is not supported!");
}
}
示例9: startByWebDriver
import org.openqa.selenium.firefox.FirefoxDriver; //导入依赖的package包/类
@Test
public void startByWebDriver() {
System.setProperty("webdriver.gecko.driver","C:\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.navigate().to("http://localhost:8080/login");
driver.findElement(By.name("username")).clear();
driver.findElement(By.name("username")).sendKeys("TestAcc1");
driver.findElement(By.name("password")).clear();
driver.findElement(By.name("password")).sendKeys("12345678");
driver.findElement(By.xpath("//button[@type='submit']")).click();
driver.navigate().to("http://localhost:8080");
driver.findElement(By.linkText("Logout")).click();
}
示例10: Firefox
import org.openqa.selenium.firefox.FirefoxDriver; //导入依赖的package包/类
/**
* 本地初始化Firefox浏览器driver
*/
public Firefox() {
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("acceptSslCerts", false);
FirefoxBrowserProfile firefoxProfile = new FirefoxBrowserProfile();
String sProfile = firefoxProfile.getDefaultProfile();
if (sProfile.equals("")) {
this.driver = new FirefoxDriver();
} else {
try {
FirefoxProfile profile = new FirefoxProfile(new File(sProfile));
FirefoxBinary firefoxBinary = new FirefoxBinary(new File(firefoxProfile.getFirefoxBinInstallPath()));
profile.setAcceptUntrustedCertificates(false);
this.driver = new FirefoxDriver(firefoxBinary, profile);
} catch (Exception e) {
throw new RuntimeException("Failed to start firefox browser,please check!", e);
}
}
}
示例11: LoginSteps
import org.openqa.selenium.firefox.FirefoxDriver; //导入依赖的package包/类
public LoginSteps() {
Referendum ref = new Referendum();
ref.setName("Ref");
ref.setStartDate(new Date());
Calendar c = Calendar.getInstance();
c.setTime(new Date());
c.add(Calendar.DATE, 1);
ref.setExpiryDate(c.getTime());
ref.setNumChoices(1);
ref.setQuestion("Question");
ref.setInstructions("Ins");
Repository.electionR.save(ref);
driver = new FirefoxDriver();
}
示例12: createWebDriver
import org.openqa.selenium.firefox.FirefoxDriver; //导入依赖的package包/类
public static WebDriver createWebDriver() throws Exception {
DesiredCapabilities capability = DesiredCapabilities.chrome();
capability.setJavascriptEnabled(true);
FirefoxProfile firefoxProfile = new FirefoxProfile();
// 鍘绘帀css
// firefoxProfile.setPreference("permissions.default.stylesheet", 2);
// 鍘绘帀鍥剧墖
// firefoxProfile.setPreference("permissions.default.image", 2);
// 鍘绘帀flash
firefoxProfile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so", false);
capability.setCapability("firefox_profile", firefoxProfile);
WebDriver driver = new FirefoxDriver(capability);
// WebDriver driver = new HtmlUnitDriver();
// WebDriver driver = new HtmlUnitDriver();
// 濡傛灉3s鍐呰繕瀹氫綅涓嶅埌鍒欐姏鍑哄紓甯?
// driver.manage().timeouts().implicitlyWait(IMPLICITLYWAIT,
// TimeUnit.SECONDS);
// 椤甸潰鍔犺浇瓒呮椂鏃堕棿璁剧疆涓?5s
// driver.manage().timeouts().pageLoadTimeout(PAGELOADTIMEOUT,
// TimeUnit.SECONDS);
// driver.manage().timeouts().setScriptTimeout(60,TimeUnit.SECONDS);
return driver;
}
示例13: createInstance
import org.openqa.selenium.firefox.FirefoxDriver; //导入依赖的package包/类
public WebDriver createInstance(Type type) {
switch (type) {
case CHROME:
return new ChromeDriver();
case CHROME_HEADLESS:
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless", "--disable-gpu");
ChromeDriver chromeDriver = new ChromeDriver(options);
return chromeDriver;
case OPERA:
return new OperaDriver(getOperaCapabilities());
case FIREFOX:
default:
return new FirefoxDriver();
}
}
示例14: init
import org.openqa.selenium.firefox.FirefoxDriver; //导入依赖的package包/类
/**
* Methods that is bound to the INIT command.
*
* @param command Command to retrieve method parameters from.
* @return <tt>true</tt> if the init command was correctly executed, <tt>false</tt> otherwise.
*/
public static CommandStatus init(final CommandLine command) {
final String contest = command.getOptionValue(CONTEST);
if (command.hasOption(INIT_METHOD)) {
final String method = command.getOptionValue(INIT_METHOD).toLowerCase();
if (FIREFOX_METHOD.equals(method)) {
return browserInit(FirefoxDriver::new, contest);
}
else if (TEXT_METHOD.equals(method)) {
return textInit(contest);
}
err.println("-> Invalid method provided (only firefox or text supported");
return CommandStatus.INVALID_FORMAT;
}
return browserInit(FirefoxDriver::new, contest);
}
示例15: f
import org.openqa.selenium.firefox.FirefoxDriver; //导入依赖的package包/类
@Test
public void f() {
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://test.zyd.onlyou.com/login.htm");
driver.manage().window();
driver.findElement(By.name("username")).click();
driver.findElement(By.name("username")).sendKeys("pancs_qd");
driver.findElement(By.name("password")).click();
driver.findElement(By.name("password")).sendKeys("111111");
driver.findElement(By.className("btn-submit")).click();
WebDriverWait wait = new WebDriverWait(driver,10);//等待最长时间10s
wait.until(new ExpectedCondition<WebElement>(){
@Override
public WebElement apply(WebDriver d){
return d.findElement(By.id(""));
}
}).click();
driver.close();
}