Java Code Examples for org.openqa.selenium.firefox.FirefoxDriver

The following are top voted examples for showing how to use org.openqa.selenium.firefox.FirefoxDriver. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: selenium-jupiter   File: FirefoxAnnotationReaderTest.java   View source code 8 votes vote down vote up
@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"));
}
 
Example 2
Project: java-maven-selenium   File: DriverFactory.java   View source code 8 votes vote down vote up
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();

        }
    }
 
Example 3
Project: selenium-cucumber-framework   File: BrowserFactory.java   View source code 7 votes vote down vote up
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");
	}
}
 
Example 4
Project: QA_Begin   File: TestContactDoq.java   View source code 6 votes vote down vote up
@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");
}
 
Example 5
Project: testing_security_development_enterprise_systems   File: SeleniumTestBase.java   View source code 6 votes vote down vote up
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);
}
 
Example 6
Project: selenium-jupiter   File: SeleniumExtension.java   View source code 6 votes vote down vote up
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);
}
 
Example 7
Project: selenium-jupiter   File: FirefoxDriverHandler.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 8
Project: selenium-camp-17   File: Java7WebDriverFactory.java   View source code 6 votes vote down vote up
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!");
	}
}
 
Example 9
Project: otinane   File: LogoutTest.java   View source code 6 votes vote down vote up
@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();

}
 
Example 10
Project: KeywordDrivenAutoTest   File: Firefox.java   View source code 6 votes vote down vote up
/**
 * 本地初始化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);
        }
    }
}
 
Example 11
Project: Voting_2b   File: LoginSteps.java   View source code 6 votes vote down vote up
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();
	}
 
Example 12
Project: alimama   File: SeleniumUtil.java   View source code 6 votes vote down vote up
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;

}
 
Example 13
Project: jwebrobot   File: WebDriverProvider.java   View source code 6 votes vote down vote up
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();
    }
}
 
Example 14
Project: googlecodejam-cli   File: ApplicationCommand.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 15
Project: cashion   File: TestBaseAssert.java   View source code 6 votes vote down vote up
@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();
 
}
 
Example 16
Project: selenium-example   File: FirefoxTest.java   View source code 6 votes vote down vote up
@Before
public void prepare() {

    testUrl = "https://leftstick.github.io/";

    System.setProperty("webdriver.gecko.driver","webdriver/geckodriver");

    // Create a new instance of the Chrome driver
    // Notice that the remainder of the code relies on the interface,
    // not the implementation.
    driver = new FirefoxDriver();

    // And now use this to visit myBlog
    // Alternatively the same thing can be done like this
    // driver.navigate().to(testUrl);
    driver.get(testUrl);
}
 
Example 17
Project: teasy   File: SeleniumTestExecutionListener.java   View source code 5 votes vote down vote up
private WebDriver firefox(final Settings settings, DesiredCapabilities customDesiredCapabilities) {
    DesiredCapabilities desiredCapabilities = getFireFoxDesiredCapabilities(settings);
    if (!customDesiredCapabilities.asMap().isEmpty()) {
        desiredCapabilities.merge(customDesiredCapabilities);
    }
    return new FirefoxDriver(desiredCapabilities);
}
 
Example 18
Project: teasy   File: SeleniumTestExecutionListener.java   View source code 5 votes vote down vote up
private WebDriver gecko(DesiredCapabilities customDesiredCapabilities) {
    FirefoxDriverManager.getInstance().setup();
    DesiredCapabilities desiredCapabilities = getGeckoDesiredCapabilities();
    if (!customDesiredCapabilities.asMap().isEmpty()) {
        desiredCapabilities.merge(customDesiredCapabilities);
    }
    return new FirefoxDriver(desiredCapabilities);
}
 
Example 19
Project: teasy   File: SeleniumTestExecutionListener.java   View source code 5 votes vote down vote up
private DesiredCapabilities getFireFoxDesiredCapabilities(Settings settings) {
    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    setAlertBehaviorCapabilities(capabilities);
    capabilities.setCapability(FirefoxDriver.MARIONETTE, false);
    capabilities.setCapability(FirefoxDriver.PROFILE, getFirefoxProfile(settings));
    capabilities.setPlatform(Platform.WINDOWS);
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    setLoggingPrefs(capabilities);
    setProxy(capabilities);
    return capabilities;
}
 
Example 20
Project: teasy   File: SeleniumTestExecutionListener.java   View source code 5 votes vote down vote up
private DesiredCapabilities getGeckoDesiredCapabilities() {
    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    setAlertBehaviorCapabilities(capabilities);
    capabilities.setCapability(FirefoxDriver.MARIONETTE, true);
    capabilities.setPlatform(Platform.WINDOWS);
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);


    setLoggingPrefs(capabilities);
    setProxy(capabilities);
    return capabilities;
}
 
Example 21
Project: teasy   File: DriverUtils.java   View source code 5 votes vote down vote up
public static WebDriver getFFDriver() {
    Settings ffSettings = new Settings();
    BeanUtils.copyProperties(SELENIUM_SETTINGS, ffSettings);
    ffSettings.setDriverName("firefox");
    driverHolder.set(new FramesTransparentWebDriver(new FirefoxDriver(getFireFoxDesiredCapabilities(ffSettings))));
    return driverHolder.get();
}
 
Example 22
Project: Learning-Spring-Boot-2.0-Second-Edition   File: FirefoxDriverFactory.java   View source code 5 votes vote down vote up
@Override
public FirefoxDriver getObject() throws BeansException {
	if (properties.getFirefox().isEnabled()) {
		try {
			return new FirefoxDriver();
		} catch (WebDriverException e) {
			e.printStackTrace();
			// swallow the exception
		}
	}
	return null;
}
 
Example 23
Project: Learning-Spring-Boot-2.0-Second-Edition   File: WebDriverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void testWithMockedFirefox() {
	load(new Class[]{MockFirefoxConfiguration.class},
		"com.greglturnquist.webdriver.safari.enabled:false",
		"com.greglturnquist.webdriver.chrome.enabled:false");
	WebDriver driver = context.getBean(WebDriver.class);
	assertThat(ClassUtils.isAssignable(TakesScreenshot.class,
		driver.getClass())).isTrue();
	assertThat(ClassUtils.isAssignable(FirefoxDriver.class,
		driver.getClass())).isTrue();
}
 
Example 24
Project: Learning-Spring-Boot-2.0-Second-Edition   File: WebDriverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Bean
FirefoxDriverFactory firefoxDriverFactory() {
	FirefoxDriverFactory factory =
		mock(FirefoxDriverFactory.class);
	given(factory.getObject())
		.willReturn(mock(FirefoxDriver.class));
	return factory;
}
 
Example 25
Project: mastering-junit5   File: LocalWebDriverTest.java   View source code 5 votes vote down vote up
@Test
public void testWithFirefoxAndOpera(FirefoxDriver firefox,
        OperaDriver opera) {
    firefox.get("http://www.seleniumhq.org/");
    opera.get("http://junit.org/junit5/");

    assertTrue(firefox.getTitle().startsWith("Selenium"));
    assertTrue(opera.getTitle().equals("JUnit 5"));
}
 
Example 26
Project: functional-programming-selenium-examples   File: Firefox.java   View source code 5 votes vote down vote up
@Override
public WebDriver getWebDriver()
{
	System.setProperty("webdriver.gecko.driver", "src/test/resources/geckodriver.v0.11.1.mac");
	DesiredCapabilities capabilities=DesiredCapabilities.firefox();
	WebDriver driver = new FirefoxDriver(capabilities);
       return driver;
}
 
Example 27
Project: java-maven-testng-starter   File: AbstractTest.java   View source code 5 votes vote down vote up
@BeforeTest
@Parameters({"url"})
public void setup(String url) {
  // Set the path to the geckodriver
  System.setProperty("webdriver.gecko.driver", "./drivers/geckodriver");
  
  // Instantiate a new Page and navigate 
  // to the url specified in the testng.xml
  page = new Page(new FirefoxDriver());
  page.navigate(url);
}
 
Example 28
Project: NoraUi   File: DriverFactory.java   View source code 5 votes vote down vote up
/**
 * Generates a firefox webdriver.
 *
 * @return
 *         A firefox webdriver
 * @throws TechnicalException
 *             if an error occured when Webdriver setExecutable to true.
 */
private WebDriver generateFirefoxDriver() throws TechnicalException {
    final String pathWebdriver = DriverFactory.getPath(Driver.FIREFOX);
    if (!new File(pathWebdriver).setExecutable(true)) {
        throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_WEBDRIVER_SET_EXECUTABLE));
    }
    logger.info("Generating Firefox driver ({}) ...", pathWebdriver);

    System.setProperty(Driver.FIREFOX.getDriverName(), pathWebdriver);

    final FirefoxOptions firefoxOptions = new FirefoxOptions();
    final FirefoxBinary firefoxBinary = new FirefoxBinary();

    final DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
    capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);

    setLoggingLevel(capabilities);

    // Proxy configuration
    if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
        capabilities.setCapability(CapabilityType.PROXY, Context.getProxy());
    }

    if (Context.isHeadless()) {
        firefoxBinary.addCommandLineOptions("--headless");
        firefoxOptions.setBinary(firefoxBinary);
    }
    firefoxOptions.setLogLevel(Level.OFF);

    capabilities.setCapability(FirefoxOptions.FIREFOX_OPTIONS, firefoxOptions);

    return new FirefoxDriver(capabilities);
}
 
Example 29
Project: Java-Data-Science-Cookbook   File: WebdataExtractionSelenium.java   View source code 5 votes vote down vote up
public static void main(String[] args) {
       WebDriver driver = new FirefoxDriver();
       driver.get("http://cogenglab.csd.uwo.ca/rushdi.htm");

       WebElement webElement = driver.findElement(By.xpath("//*[@id='content']"));
	System.out.println(webElement.getText());
	
}
 
Example 30
Project: QA_Begin   File: TestFindGoogle.java   View source code 5 votes vote down vote up
@Before
public  void setUpTest(){
    System.setProperty("webdriver.gecko.driver", "C:\\webdriver\\geckodriver-v0.11.1-win64\\geckodriver.exe");
    driver = new FirefoxDriver();
    driver.manage().window().maximize();
    driver.get("http://www.google.com");

}
 
Example 31
Project: mpay24-java   File: AbstractSeleniumTestcase.java   View source code 5 votes vote down vote up
protected RemoteWebDriver openFirefoxAtUrl(String url) {
		String geckoDriver = getGeckoDriver();
		if (geckoDriver != null)
			System.setProperty("webdriver.gecko.driver", geckoDriver);
		driver = new FirefoxDriver();
		driver.get(url);
		return driver;

//		driver = new ChromeDriver();
//		driver.get(url);
//		return driver;
	}
 
Example 32
Project: selenium-jupiter   File: FirefoxWithGlobalOptionsJupiterTest.java   View source code 5 votes vote down vote up
@Test
public void webrtcTest(FirefoxDriver driver) {
    driver.get(
            "https://webrtc.github.io/samples/src/content/devices/input-output/");
    assertThat(driver.findElement(By.id("video")).getTagName(),
            equalTo("video"));
}
 
Example 33
Project: selenium-jupiter   File: FirefoxWithOptionsJupiterTest.java   View source code 5 votes vote down vote up
@Test
public void webrtcTest(@Arguments("-private") @Preferences({
        "media.navigator.permission.disabled=true",
        "media.navigator.streams.fake=true" }) FirefoxDriver driver) {
    driver.get(
            "https://webrtc.github.io/samples/src/content/devices/input-output/");
    assertThat(driver.findElement(By.id("video")).getTagName(),
            equalTo("video"));
}
 
Example 34
Project: selenium-jupiter   File: SeleniumJupiterTest.java   View source code 5 votes vote down vote up
@Test
public void testWithChromeAndFirefox(ChromeDriver driver1,
        FirefoxDriver driver2) {
    driver1.get("http://www.seleniumhq.org/");
    driver2.get("http://junit.org/junit5/");
    assertThat(driver1.getTitle(), startsWith("Selenium"));
    assertThat(driver2.getTitle(), equalTo("JUnit 5"));
}
 
Example 35
Project: selenium-jupiter   File: FirefoxJupiterTest.java   View source code 5 votes vote down vote up
@Disabled("Redudant test for Travis CI suite")
// tag::snippet-in-doc[]
@Test
public void testWithTwoFirefoxs(FirefoxDriver driver1,
        FirefoxDriver driver2) {
    driver1.get("http://www.seleniumhq.org/");
    driver2.get("http://junit.org/junit5/");
    assertThat(driver1.getTitle(), startsWith("Selenium"));
    assertThat(driver2.getTitle(), equalTo("JUnit 5"));
}
 
Example 36
Project: selenium-jupiter   File: ForcedAnnotationReaderTest.java   View source code 5 votes vote down vote up
static Stream<Arguments> forcedTestProvider() {
    return Stream.of(
            Arguments.of(AppiumDriverHandler.class,
                    ForcedAppiumJupiterTest.class, AppiumDriver.class,
                    "appiumNoCapabilitiesTest"),
            Arguments.of(AppiumDriverHandler.class,
                    ForcedAppiumJupiterTest.class, AppiumDriver.class,
                    "appiumWithCapabilitiesTest"),
            Arguments.of(ChromeDriverHandler.class,
                    ForcedBadChromeJupiterTest.class, ChromeDriver.class,
                    "chromeTest"),
            Arguments.of(FirefoxDriverHandler.class,
                    ForcedBadFirefoxJupiterTest.class, FirefoxDriver.class,
                    "firefoxTest"),
            Arguments.of(RemoteDriverHandler.class,
                    ForcedBadRemoteJupiterTest.class, RemoteWebDriver.class,
                    "remoteTest"),
            Arguments.of(EdgeDriverHandler.class,
                    ForcedEdgeJupiterTest.class, EdgeDriver.class,
                    "edgeTest"),
            Arguments.of(OperaDriverHandler.class,
                    ForcedOperaJupiterTest.class, OperaDriver.class,
                    "operaTest"),
            Arguments.of(SafariDriverHandler.class,
                    ForcedSafariJupiterTest.class, SafariDriver.class,
                    "safariTest"));
}
 
Example 37
Project: oldmonk   File: WebCapabilitiesBuilder.java   View source code 5 votes vote down vote up
@Override
public WebCapabilitiesBuilder addBrowserProfile(BrowserProfile browserProfile) throws CapabilityNotPresentException
{
    String browser = capabilities.getBrowserName();

    if (browser.equalsIgnoreCase("firefox"))
    {
        if (browserProfile instanceof FirefoxBrowserProfile)
        {
            capabilities.setCapability(FirefoxDriver.PROFILE, browserProfile.createProfile());
        }

    } else if (browser.equalsIgnoreCase("ie"))
    {
        if (browserProfile instanceof IEBrowserProfile)
        {
            @SuppressWarnings("unchecked")
            Map<String, Boolean> ieCapabilities = (Map<String, Boolean>) browserProfile.createProfile();
            Iterator<Map.Entry<String, Boolean>> it = ieCapabilities.entrySet().iterator();

            while (it.hasNext())
            {
                Map.Entry<String, Boolean> keyValuePair = it.next();
                capabilities.setCapability(keyValuePair.getKey(), keyValuePair.getValue());
            }
        }
    } else if (browser.equalsIgnoreCase("chrome"))
    {
        if (browserProfile instanceof ChromeBrowserProfile)
        {
            capabilities.setCapability(ChromeOptions.CAPABILITY, browserProfile.createProfile());
        }
    } else
    {
        throw new CapabilityNotPresentException("Unable to create capability for adding browser profile!");
    }

    return this;
}
 
Example 38
Project: Java-Testing-Toolbox   File: FirefoxConfiguration.java   View source code 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public FirefoxDriver start(Capabilities other) {
    Capabilities capabilities = this.mergeCapabilities(other);

    if (capabilities == null) {
        return new FirefoxDriver();
    }

    return new FirefoxDriver(capabilities);
}
 
Example 39
Project: Java-Testing-Toolbox   File: SeleniumConfiguration.java   View source code 5 votes vote down vote up
/**
 * Load the default configuration. It will not erase previous non-default configurations.
 * 
 * @return Itself.
 */
public SeleniumConfiguration loadDefaultConfiguration() {
    this.getConfiguration().put(ChromeDriver.class, new ChromeConfiguration());
    this.getConfiguration().put(EdgeDriver.class, new EdgeConfiguration());
    this.getConfiguration().put(FirefoxDriver.class, new FirefoxConfiguration());
    this.getConfiguration().put(HtmlUnitConfiguration.class, new HtmlUnitConfiguration());
    this.getConfiguration().put(InternetExplorerConfiguration.class, new InternetExplorerConfiguration());
    this.getConfiguration().put(OperaConfiguration.class, new OperaConfiguration());
    this.getConfiguration().put(PhantomJSConfiguration.class, new PhantomJSConfiguration());
    this.getConfiguration().put(SafariDriver.class, new SafariConfiguration());

    return this;
}
 
Example 40
Project: Mastering-Software-Testing-with-JUnit-5   File: LocalWebDriverTest.java   View source code 5 votes vote down vote up
@Test
public void testWithFirefoxAndOpera(FirefoxDriver firefox,
        OperaDriver opera) {
    firefox.get("http://www.seleniumhq.org/");
    opera.get("http://junit.org/junit5/");

    assertTrue(firefox.getTitle().startsWith("Selenium"));
    assertTrue(opera.getTitle().equals("JUnit 5"));
}