當前位置: 首頁>>代碼示例>>Java>>正文


Java FirefoxDriver類代碼示例

本文整理匯總了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"));
}
 
開發者ID:bonigarcia,項目名稱:selenium-jupiter,代碼行數:19,代碼來源:FirefoxAnnotationReaderTest.java

示例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();

        }
    }
 
開發者ID:getgauge-examples,項目名稱:java-maven-selenium,代碼行數:22,代碼來源:DriverFactory.java

示例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");
	}
}
 
開發者ID:Spence1115,項目名稱:selenium-cucumber-framework,代碼行數:17,代碼來源:BrowserFactory.java

示例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");
}
 
開發者ID:vitorc,項目名稱:QA_Begin,代碼行數:11,代碼來源:TestContactDoq.java

示例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);
}
 
開發者ID:bonigarcia,項目名稱:selenium-jupiter,代碼行數:23,代碼來源:SeleniumExtension.java

示例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);
    }
}
 
開發者ID:bonigarcia,項目名稱:selenium-jupiter,代碼行數:17,代碼來源:FirefoxDriverHandler.java

示例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!");
	}
}
 
開發者ID:sskorol,項目名稱:selenium-camp-17,代碼行數:17,代碼來源:Java7WebDriverFactory.java

示例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();

}
 
開發者ID:InvertedHellWorkshop,項目名稱:otinane,代碼行數:17,代碼來源:LogoutTest.java

示例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);
        }
    }
}
 
開發者ID:Airpy,項目名稱:KeywordDrivenAutoTest,代碼行數:22,代碼來源:Firefox.java

示例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();
	}
 
開發者ID:Arquisoft,項目名稱:Voting_2b,代碼行數:17,代碼來源:LoginSteps.java

示例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;

}
 
開發者ID:xiaomin0322,項目名稱:alimama,代碼行數:27,代碼來源:SeleniumUtil.java

示例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();
    }
}
 
開發者ID:automate-website,項目名稱:jwebrobot,代碼行數:18,代碼來源:WebDriverProvider.java

示例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);
}
 
開發者ID:Faylixe,項目名稱:googlecodejam-cli,代碼行數:22,代碼來源:ApplicationCommand.java

示例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();
 
}
 
開發者ID:pcsh,項目名稱:cashion,代碼行數:22,代碼來源:TestBaseAssert.java


注:本文中的org.openqa.selenium.firefox.FirefoxDriver類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。