Search in sources :

Example 41 with FirefoxDriver

use of org.openqa.selenium.firefox.FirefoxDriver in project h2o-2 by h2oai.

the class Test24 method setUp.

@Before
public void setUp() throws Exception {
    driver = new FirefoxDriver();
    baseUrl = "http://0.0.0.0:11185";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
Also used : FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver)

Example 42 with FirefoxDriver

use of org.openqa.selenium.firefox.FirefoxDriver in project webmagic by code4craft.

the class WebDriverPool method configure.

/**
	 * Configure the GhostDriver, and initialize a WebDriver instance. This part
	 * of code comes from GhostDriver.
	 * https://github.com/detro/ghostdriver/tree/master/test/java/src/test/java/ghostdriver
	 * 
	 * @author bob.li.0718@gmail.com
	 * @throws IOException
	 */
public void configure() throws IOException {
    // Read config file
    sConfig = new Properties();
    String configFile = DEFAULT_CONFIG_FILE;
    if (System.getProperty("selenuim_config") != null) {
        configFile = System.getProperty("selenuim_config");
    }
    sConfig.load(new FileReader(configFile));
    // Prepare capabilities
    sCaps = new DesiredCapabilities();
    sCaps.setJavascriptEnabled(true);
    sCaps.setCapability("takesScreenshot", false);
    String driver = sConfig.getProperty("driver", DRIVER_PHANTOMJS);
    // Fetch PhantomJS-specific configuration parameters
    if (driver.equals(DRIVER_PHANTOMJS)) {
        // "phantomjs_exec_path"
        if (sConfig.getProperty("phantomjs_exec_path") != null) {
            sCaps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, sConfig.getProperty("phantomjs_exec_path"));
        } else {
            throw new IOException(String.format("Property '%s' not set!", PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY));
        }
        // "phantomjs_driver_path"
        if (sConfig.getProperty("phantomjs_driver_path") != null) {
            System.out.println("Test will use an external GhostDriver");
            sCaps.setCapability(PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_PATH_PROPERTY, sConfig.getProperty("phantomjs_driver_path"));
        } else {
            System.out.println("Test will use PhantomJS internal GhostDriver");
        }
    }
    // Disable "web-security", enable all possible "ssl-protocols" and
    // "ignore-ssl-errors" for PhantomJSDriver
    // sCaps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new
    // String[] {
    // "--web-security=false",
    // "--ssl-protocol=any",
    // "--ignore-ssl-errors=true"
    // });
    ArrayList<String> cliArgsCap = new ArrayList<String>();
    cliArgsCap.add("--web-security=false");
    cliArgsCap.add("--ssl-protocol=any");
    cliArgsCap.add("--ignore-ssl-errors=true");
    sCaps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgsCap);
    // Control LogLevel for GhostDriver, via CLI arguments
    sCaps.setCapability(PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_CLI_ARGS, new String[] { "--logLevel=" + (sConfig.getProperty("phantomjs_driver_loglevel") != null ? sConfig.getProperty("phantomjs_driver_loglevel") : "INFO") });
    // Start appropriate Driver
    if (isUrl(driver)) {
        sCaps.setBrowserName("phantomjs");
        mDriver = new RemoteWebDriver(new URL(driver), sCaps);
    } else if (driver.equals(DRIVER_FIREFOX)) {
        mDriver = new FirefoxDriver(sCaps);
    } else if (driver.equals(DRIVER_CHROME)) {
        mDriver = new ChromeDriver(sCaps);
    } else if (driver.equals(DRIVER_PHANTOMJS)) {
        mDriver = new PhantomJSDriver(sCaps);
    }
}
Also used : PhantomJSDriver(org.openqa.selenium.phantomjs.PhantomJSDriver) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ArrayList(java.util.ArrayList) FileReader(java.io.FileReader) IOException(java.io.IOException) Properties(java.util.Properties) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) URL(java.net.URL)

Example 43 with FirefoxDriver

use of org.openqa.selenium.firefox.FirefoxDriver in project zeppelin by apache.

the class WebDriverManager method getWebDriver.

public static WebDriver getWebDriver() {
    WebDriver driver = null;
    if (driver == null) {
        try {
            FirefoxBinary ffox = new FirefoxBinary();
            if ("true".equals(System.getenv("TRAVIS"))) {
                // xvfb is supposed to
                ffox.setEnvironmentProperty("DISPLAY", ":99");
            // run with DISPLAY 99
            }
            int firefoxVersion = WebDriverManager.getFirefoxVersion();
            LOG.info("Firefox version " + firefoxVersion + " detected");
            downLoadsDir = FileUtils.getTempDirectory().toString();
            String tempPath = downLoadsDir + "/firebug/";
            downloadFireBug(firefoxVersion, tempPath);
            final String firebugPath = tempPath + "firebug.xpi";
            final String firepathPath = tempPath + "firepath.xpi";
            FirefoxProfile profile = new FirefoxProfile();
            profile.setPreference("browser.download.folderList", 2);
            profile.setPreference("browser.download.dir", downLoadsDir);
            profile.setPreference("browser.helperApps.alwaysAsk.force", false);
            profile.setPreference("browser.download.manager.showWhenStarting", false);
            profile.setPreference("browser.download.manager.showAlertOnComplete", false);
            profile.setPreference("browser.download.manager.closeWhenDone", true);
            profile.setPreference("app.update.auto", false);
            profile.setPreference("app.update.enabled", false);
            profile.setPreference("dom.max_script_run_time", 0);
            profile.setPreference("dom.max_chrome_script_run_time", 0);
            profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/x-ustar,application/octet-stream,application/zip,text/csv,text/plain");
            profile.setPreference("network.proxy.type", 0);
            profile.addExtension(new File(firebugPath));
            profile.addExtension(new File(firepathPath));
            driver = new FirefoxDriver(ffox, profile);
        } catch (Exception e) {
            LOG.error("Exception in WebDriverManager while FireFox Driver ", e);
        }
    }
    if (driver == null) {
        try {
            driver = new ChromeDriver();
        } catch (Exception e) {
            LOG.error("Exception in WebDriverManager while ChromeDriver ", e);
        }
    }
    if (driver == null) {
        try {
            driver = new SafariDriver();
        } catch (Exception e) {
            LOG.error("Exception in WebDriverManager while SafariDriver ", e);
        }
    }
    String url;
    if (System.getenv("url") != null) {
        url = System.getenv("url");
    } else {
        url = "http://localhost:8080";
    }
    long start = System.currentTimeMillis();
    boolean loaded = false;
    driver.manage().timeouts().implicitlyWait(AbstractZeppelinIT.MAX_IMPLICIT_WAIT, TimeUnit.SECONDS);
    driver.get(url);
    while (System.currentTimeMillis() - start < 60 * 1000) {
        // wait for page load
        try {
            (new WebDriverWait(driver, 30)).until(new ExpectedCondition<Boolean>() {

                @Override
                public Boolean apply(WebDriver d) {
                    return d.findElement(By.xpath("//i[@tooltip='WebSocket Connected']")).isDisplayed();
                }
            });
            loaded = true;
            break;
        } catch (TimeoutException e) {
            LOG.info("Exception in WebDriverManager while WebDriverWait ", e);
            driver.navigate().to(url);
        }
    }
    if (loaded == false) {
        fail();
    }
    return driver;
}
Also used : WebDriver(org.openqa.selenium.WebDriver) FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile) IOException(java.io.IOException) TimeoutException(org.openqa.selenium.TimeoutException) SafariDriver(org.openqa.selenium.safari.SafariDriver) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) FirefoxBinary(org.openqa.selenium.firefox.FirefoxBinary) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) File(java.io.File) TimeoutException(org.openqa.selenium.TimeoutException)

Example 44 with FirefoxDriver

use of org.openqa.selenium.firefox.FirefoxDriver in project java.webdriver by sayems.

the class SwitchBetweenFrames method main.

public static void main(String... args) {
    WebDriver driver = new FirefoxDriver();
    driver.get("file://///vmware-host/Shared Folders/Desktop/IFrames.html");
    Actions action = new Actions(driver);
    driver.switchTo().frame(0);
    WebElement txt = driver.findElement(By.name("1"));
    txt.sendKeys("I'm Frame One");
    driver.switchTo().defaultContent();
    driver.switchTo().frame(1);
    txt = driver.findElement(By.name("2"));
    txt.sendKeys("I'm Frame Two");
}
Also used : WebDriver(org.openqa.selenium.WebDriver) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) Actions(org.openqa.selenium.interactions.Actions) WebElement(org.openqa.selenium.WebElement)

Example 45 with FirefoxDriver

use of org.openqa.selenium.firefox.FirefoxDriver in project java.webdriver by sayems.

the class SelectExample method setUp.

@BeforeClass
public void setUp() {
    driver = new FirefoxDriver();
    driver.navigate().to("http://seleniumhq.org/docs/03_webdriver.html#user-input-filling-in-forms");
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
Also used : FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)82 WebDriver (org.openqa.selenium.WebDriver)61 WebElement (org.openqa.selenium.WebElement)47 Actions (org.openqa.selenium.interactions.Actions)18 FirefoxProfile (org.openqa.selenium.firefox.FirefoxProfile)10 File (java.io.File)8 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)7 FirefoxBinary (org.openqa.selenium.firefox.FirefoxBinary)6 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)5 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)5 URL (java.net.URL)4 Before (org.junit.Before)4 PhantomJSDriver (org.openqa.selenium.phantomjs.PhantomJSDriver)4 Test (org.junit.Test)3 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)3 PublicAtsApi (com.axway.ats.common.PublicAtsApi)2 FileReader (java.io.FileReader)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2