本文整理匯總了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();
}