Search in sources :

Example 1 with FirefoxBinary

use of org.openqa.selenium.firefox.FirefoxBinary in project Asqatasun by Asqatasun.

the class FirefoxDriverFactory method make.

/**
     * 
     * @param config
     * @return A FirefoxDriver.
     */
@Override
public RemoteWebDriver make(HashMap<String, String> config) {
    FirefoxBinary ffBinary = new FirefoxBinary();
    if (System.getProperty(DISPLAY_PROPERTY) != null) {
        ffBinary.setEnvironmentProperty(DISPLAY_PROPERTY.toUpperCase(), System.getProperty(DISPLAY_PROPERTY));
    } else if (System.getenv(DISPLAY_PROPERTY.toUpperCase()) != null) {
        ffBinary.setEnvironmentProperty(DISPLAY_PROPERTY.toUpperCase(), System.getenv(DISPLAY_PROPERTY.toUpperCase()));
    }
    RemoteWebDriver remoteWebDriver = new FirefoxDriver(ffBinary, firefoxProfile);
    if (screenHeight != -1 && screenWidth != -1) {
        remoteWebDriver.manage().window().setSize(new Dimension(screenWidth, screenHeight));
    }
    return remoteWebDriver;
}
Also used : FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) FirefoxBinary(org.openqa.selenium.firefox.FirefoxBinary) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) Dimension(org.openqa.selenium.Dimension)

Example 2 with FirefoxBinary

use of org.openqa.selenium.firefox.FirefoxBinary in project Asqatasun by Asqatasun.

the class FirefoxDriverPoolableObjectFactory method makeObject.

@Override
public FirefoxDriver makeObject() throws Exception {
    FirefoxBinary ffBinary = new FirefoxBinary();
    if (System.getProperty(DISPLAY_PROPERTY_KEY) != null) {
        Logger.getLogger(this.getClass()).info("Setting Xvfb display with value " + System.getProperty(DISPLAY_PROPERTY_KEY));
        ffBinary.setEnvironmentProperty("DISPLAY", System.getProperty(DISPLAY_PROPERTY_KEY));
    }
    FirefoxDriver fd = new FirefoxDriver(ffBinary, ProfileFactory.getInstance().getScenarioProfile());
    if (this.implicitelyWaitDriverTimeout != null) {
        fd.manage().timeouts().implicitlyWait(this.implicitelyWaitDriverTimeout.longValue(), TimeUnit.SECONDS);
    }
    if (this.pageLoadDriverTimeout != null) {
        fd.manage().timeouts().pageLoadTimeout(this.pageLoadDriverTimeout.longValue(), TimeUnit.SECONDS);
    }
    return fd;
}
Also used : FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) FirefoxBinary(org.openqa.selenium.firefox.FirefoxBinary)

Example 3 with FirefoxBinary

use of org.openqa.selenium.firefox.FirefoxBinary in project mamute by caelum.

the class AcceptanceTestBase method buildDriver.

@BeforeClass
public static void buildDriver() {
    // System.setProperty("webdriver.chrome.driver",
    // "/home/csokol/programas/chromedriver/chromedriver");
    // driver = new ChromeDriver();
    String localTest = System.getenv("LOCAL_TEST");
    if ("remote".equals(localTest)) {
        driver = ghostDriver();
    } else {
        FirefoxBinary firefox = new FirefoxBinary();
        String display = System.getProperty("DISPLAY", ":0");
        firefox.setEnvironmentProperty("DISPLAY", display);
        driver = new FirefoxDriver();
    }
    driver.manage().window().setSize(new Dimension(1280, 800));
    waitForFirstBodyPresence();
}
Also used : FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) FirefoxBinary(org.openqa.selenium.firefox.FirefoxBinary) Dimension(org.openqa.selenium.Dimension) BeforeClass(org.junit.BeforeClass)

Example 4 with FirefoxBinary

use of org.openqa.selenium.firefox.FirefoxBinary in project Asqatasun by Asqatasun.

the class AbstractWebDriverTestClass method initialize.

/**
 */
private void initialize() {
    // Mysql access parameters are passed as JVM argument
    // dbUrl = System.getProperty(DB_URL_KEY);
    // dbName = System.getProperty(DB_NAME_KEY);
    // dbUser = System.getProperty(DB_USER_KEY);
    // dbPassword = System.getProperty(DB_PASSWORD_KEY);
    // initDb();
    // These parameters has to passed as JVM argument
    user = System.getProperty(USER_KEY);
    password = System.getProperty(PASSWORD_KEY);
    hostLocation = System.getProperty(HOST_LOCATION_KEY);
    xvfbDisplay = System.getProperty(XVFB_DISPLAY_KEY);
    pathToFirefox = System.getProperty(FIREFOX_PATH_KEY);
    // createRootUserInDb();
    ResourceBundle parametersBundle = ResourceBundle.getBundle(BUNDLE_NAME);
    userFieldName = parametersBundle.getString(USER_FIELD_NAME_KEY);
    passwordFieldName = parametersBundle.getString(PASSWORD_FIELD_NAME_KEY);
    loginUrl = hostLocation + parametersBundle.getString(LOGIN_URL_KEY);
    logoutUrl = hostLocation + parametersBundle.getString(LOGOUT_URL_KEY);
    adminUrl = hostLocation + parametersBundle.getString(ADMIN_URL_KEY);
    addUserUrl = hostLocation + parametersBundle.getString(ADD_USER_URL_KEY);
    editUserUrl = hostLocation + parametersBundle.getString(EDIT_USER_URL_KEY);
    deleteUserUrl = hostLocation + parametersBundle.getString(DELETE_USER_URL_KEY);
    addContractUrl = hostLocation + parametersBundle.getString(ADD_CONTRACT_URL_KEY);
    contractUrl = hostLocation + parametersBundle.getString(CONTRACT_URL_KEY);
    auditPagesSetupUrl = hostLocation + parametersBundle.getString(AUDIT_PAGES_URL_KEY);
    auditSiteSetupUrl = hostLocation + parametersBundle.getString(AUDIT_SITE_URL_KEY);
    auditUploadSetupUrl = hostLocation + parametersBundle.getString(AUDIT_UPLOAD_URL_KEY);
    auditScenarioSetupUrl = hostLocation + parametersBundle.getString(AUDIT_SCENARIO_URL_KEY);
    addUserContractUrl = hostLocation + parametersBundle.getString(ADD_USER_CONTRACT_URL_KEY);
    editUserContractUrl = hostLocation + parametersBundle.getString(EDIT_USER_CONTRACT_URL_KEY);
    if (driver == null) {
        FirefoxBinary ffBinary = new FirefoxBinary(new File(pathToFirefox));
        if (xvfbDisplay != null) {
            Logger.getLogger(this.getClass()).info("Setting Xvfb display with value " + xvfbDisplay);
            ffBinary.setEnvironmentProperty("DISPLAY", xvfbDisplay);
        }
        driver = new FirefoxDriver(ffBinary, new FirefoxProfile());
    }
}
Also used : FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) FirefoxBinary(org.openqa.selenium.firefox.FirefoxBinary) ResourceBundle(java.util.ResourceBundle) FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile) File(java.io.File)

Example 5 with FirefoxBinary

use of org.openqa.selenium.firefox.FirefoxBinary in project NoraUi by NoraUi.

the class DriverFactory method generateFirefoxDriver.

/**
 * 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);
}
Also used : FirefoxOptions(org.openqa.selenium.firefox.FirefoxOptions) TechnicalException(com.github.noraui.exception.TechnicalException) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) FirefoxBinary(org.openqa.selenium.firefox.FirefoxBinary) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) File(java.io.File)

Aggregations

FirefoxBinary (org.openqa.selenium.firefox.FirefoxBinary)9 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)9 FirefoxProfile (org.openqa.selenium.firefox.FirefoxProfile)4 FirefoxOptions (org.openqa.selenium.firefox.FirefoxOptions)3 File (java.io.File)2 Dimension (org.openqa.selenium.Dimension)2 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)2 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)2 TechnicalException (com.github.noraui.exception.TechnicalException)1 URL (java.net.URL)1 UnknownHostException (java.net.UnknownHostException)1 ResourceBundle (java.util.ResourceBundle)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 SauceLabsConnection (org.jenkinsci.test.acceptance.utils.SauceLabsConnection)1 BeforeClass (org.junit.BeforeClass)1 Statement (org.junit.runners.model.Statement)1 WebElement (org.openqa.selenium.WebElement)1 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)1 ChromeDriverService (org.openqa.selenium.chrome.ChromeDriverService)1 ChromeOptions (org.openqa.selenium.chrome.ChromeOptions)1