List of usage examples for org.openqa.selenium.firefox FirefoxBinary FirefoxBinary
public FirefoxBinary(File pathToFirefoxBinary)
From source file:org.glassfish.tyrus.tests.qa.SeleniumToolkit.java
License:Open Source License
public void setUpFirefox() { try {/*from w ww.j a v a2s . co m*/ FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("network.proxy.type", 0); if (onWindows()) { assert new File(WIN_FIREFOX_BIN).exists() : WIN_FIREFOX_BIN + " exists"; driver = new FirefoxDriver(new FirefoxBinary(new File(WIN_FIREFOX_BIN)), profile); } else { driver = new FirefoxDriver(profile); } commonBrowserSetup(); logger.log(Level.INFO, "FF Setup PASSED"); } catch (Exception ex) { logger.log(Level.SEVERE, "FF Setup FAILED: {0}", ex.getLocalizedMessage()); ex.printStackTrace(); } finally { assert driver != null : "Driver is null"; } }
From source file:org.jboss.pressgang.ccms.page.WebDriverFactory.java
License:Open Source License
private WebDriver configureFirefoxDriver() { final String pathToFirefox = Strings.emptyToNull(PropertiesHolder.properties.getProperty("firefox.path")); FirefoxBinary firefoxBinary = null;// www. j a va2 s . c o m if (pathToFirefox != null) { firefoxBinary = new FirefoxBinary(new File(pathToFirefox)); } else { firefoxBinary = new FirefoxBinary(); } /* * TODO: Evaluate current timeout * Timeout the connection in 30 seconds * firefoxBinary.setTimeout(TimeUnit.SECONDS.toMillis(30)); */ firefoxBinary.setEnvironmentProperty("DISPLAY", PropertiesHolder.properties.getProperty("webdriver.display")); return new FirefoxDriver(firefoxBinary, makeFirefoxProfile()); }
From source file:org.openlmis.UiUtils.DriverFactory.java
License:Open Source License
private WebDriver createFirefoxDriver(boolean enableJavascript) { boolean headless = Boolean.parseBoolean(getProperty("headless", "false")); FirefoxProfile profile = new FirefoxProfile(); profile.setAcceptUntrustedCertificates(true); profile.setPreference("signed.applets.codebase_principal_support", true); profile.setPreference("javascript.enabled", enableJavascript); profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/csv"); profile.setPreference("browser.download.dir", new File(System.getProperty("user.dir")).getParent()); profile.setPreference("browser.download.folderList", 2); profile.setPreference("dom.storage.enabled", true); profile.setPreference("device.storage.enabled", true); if ((getProperty("os.name").toLowerCase().contains("mac")) && headless) { String LOCAL_FIREFOX_X11_PATH = "/opt/local/bin/firefox-x11"; File binaryFile = new File(LOCAL_FIREFOX_X11_PATH); FirefoxBinary binary = new FirefoxBinary(binaryFile); String LOCAL_X11_DISPLAY = ":5"; binary.setEnvironmentProperty("DISPLAY", LOCAL_X11_DISPLAY); return new FirefoxDriver(binary, profile); }/*from w ww. j a v a2 s . com*/ return new FirefoxDriver(profile); }
From source file:org.qe4j.web.OpenWebDriver.java
License:Open Source License
/** * Start a new FireFox browser.//from w w w. ja va 2s. c o m * * @param browserBinaryPath * @param profile * @return WebDriver instance for FireFox */ protected synchronized static WebDriver newLocalFirefoxDriver(String browserBinaryPath, FirefoxProfile profile) { WebDriver driver; if (browserBinaryPath != null) { FirefoxBinary binary = new FirefoxBinary(new File(browserBinaryPath)); driver = new FirefoxDriver(binary, profile); } else { driver = new FirefoxDriver(profile); } return driver; }
From source file:org.testeditor.fixture.web.WebDriverFixture.java
License:Open Source License
/** * starts Firefox Portable. This works for Versions < 47.0. preferably Firefox * ESR 45.4.0/*from w w w . ja va 2s .co m*/ * * @param browserPath * @return {@code WebDriver} */ @FixtureMethod public WebDriver startFireFoxPortable(String browserPath) throws FixtureException { logger.debug("Starting Firefox Portable on path : {} ...", browserPath); setupDrivermanager(FirefoxDriverManager.getInstance(DriverManagerType.FIREFOX)); logger.trace("WebDriverManager setup executed!"); FirefoxBinary binary = new FirefoxBinary(new File(browserPath)); FirefoxOptions options = new FirefoxOptions(); options.setBinary(binary); FirefoxDriver firefoxdriver = new FirefoxDriver(options); driver = firefoxdriver; logger.trace("Firefox portable setup executed!"); logBrowserVersion(options, firefoxdriver); return driver; }
From source file:org.zanata.page.WebDriverFactory.java
License:Open Source License
private EventFiringWebDriver configureFirefoxDriver() { final String pathToFirefox = Strings.emptyToNull(PropertiesHolder.properties.getProperty("firefox.path")); FirefoxBinary firefoxBinary;/*from ww w. j a va2s . c om*/ if (pathToFirefox != null) { firefoxBinary = new FirefoxBinary(new File(pathToFirefox)); } else { firefoxBinary = new FirefoxBinary(); } DesiredCapabilities capabilities = DesiredCapabilities.firefox(); enableLogging(capabilities); return new EventFiringWebDriver(new FirefoxDriver(firefoxBinary, makeFirefoxProfile(), capabilities)); }
From source file:Utility.NRICGenerator.java
public String nric_generator() throws InterruptedException { File pathfirefox = new File("C:\\Program Files\\Java\\firefox.exe"); FirefoxProfile profile = new FirefoxProfile(); driver = new FirefoxDriver(new FirefoxBinary(pathfirefox), profile); driver.get("http://xeroy.net/nric-generator/"); Thread.sleep(5000);/* www. ja va 2s .c o m*/ WebElement element = driver.findElement(By.xpath("//input[@name='xeroyNRIC' and @class='Textfield']")); try { //JavascriptExecutor executor = (JavascriptExecutor)driver; //executor.executeScript("arguments[0].click();", element); Thread.sleep(1000); } catch (InterruptedException ex) { Logger.getLogger(NRICGenerator.class.getName()).log(Level.SEVERE, null, ex); } String nric = element.getAttribute("value"); System.out.print("NRIC is generated : " + nric); return nric; }