Example usage for org.openqa.selenium.firefox FirefoxProfile ALLOWED_HOSTS_PREFERENCE

List of usage examples for org.openqa.selenium.firefox FirefoxProfile ALLOWED_HOSTS_PREFERENCE

Introduction

In this page you can find the example usage for org.openqa.selenium.firefox FirefoxProfile ALLOWED_HOSTS_PREFERENCE.

Prototype

String ALLOWED_HOSTS_PREFERENCE

To view the source code for org.openqa.selenium.firefox FirefoxProfile ALLOWED_HOSTS_PREFERENCE.

Click Source Link

Usage

From source file:edu.usc.cs.ir.selenium.handler.Arguntrader.java

License:Apache License

public static void main(String[] args) {
    Arguntrader glocktalk = new Arguntrader();
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference(FirefoxProfile.ALLOWED_HOSTS_PREFERENCE, "localhost");
    profile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so", "false");
    profile.setPreference("permissions.default.stylesheet", 1);
    profile.setPreference("permissions.default.image", 1);

    FirefoxBinary binary = new FirefoxBinary();
    binary.setTimeout(TimeUnit.SECONDS.toMillis(180));

    WebDriver driver = new FirefoxDriver(binary, profile);
    driver.manage().timeouts().pageLoadTimeout(10000, TimeUnit.MILLISECONDS);

    try {//from   ww w.j a v a 2 s.c  om
        driver.get("http://arguntrader.com/viewforum.php?f=8");
        System.out.println(new String(glocktalk.processDriver(driver).getBytes("UTF-8")));
    } catch (Exception e) {
        if (e instanceof TimeoutException) {
            System.out.println("Timeout Exception");

            try {
                System.out.println(new String(glocktalk.processDriver(driver).getBytes("UTF-8")));
            } catch (UnsupportedEncodingException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

        }
        e.printStackTrace();
    } finally {
        if (driver != null) {
            driver.close();
            driver.quit();
        }
    }
}

From source file:edu.usc.cs.ir.selenium.handler.Glocktalk.java

License:Apache License

public static void main(String[] args) {
    Glocktalk glocktalk = new Glocktalk();
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference(FirefoxProfile.ALLOWED_HOSTS_PREFERENCE, "localhost");
    profile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so", "false");
    profile.setPreference("permissions.default.stylesheet", 1);
    profile.setPreference("permissions.default.image", 1);

    FirefoxBinary binary = new FirefoxBinary();
    binary.setTimeout(TimeUnit.SECONDS.toMillis(180));

    WebDriver driver = new FirefoxDriver(binary, profile);
    driver.manage().timeouts().pageLoadTimeout(10000, TimeUnit.MILLISECONDS);

    try {/*from w  w  w  . j av  a 2 s .c om*/
        driver.get("http://www.glocktalk.com/media?page=6");
        System.out.println(new String(glocktalk.processDriver(driver).getBytes("UTF-8")));
    } catch (Exception e) {
        if (e instanceof TimeoutException) {
            System.out.println("Timeout Exception");

            try {
                System.out.println(new String(glocktalk.processDriver(driver).getBytes("UTF-8")));
            } catch (UnsupportedEncodingException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

        }
        //e.printStackTrace();
    } finally {
        if (driver != null) {
            driver.close();
            driver.quit();
        }
    }
}