Example usage for org.openqa.selenium.firefox FirefoxDriver FirefoxDriver

List of usage examples for org.openqa.selenium.firefox FirefoxDriver FirefoxDriver

Introduction

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

Prototype

public FirefoxDriver() 

Source Link

Usage

From source file:com.ceiwc.compugain.setup.TestBase.java

/**
 *  Initializes web driver object based on the browser type
 * @param sbrowser : THe browser we need to run
 * @param surl : the URL of the application
 * @return : Webdriver object/*w  w  w  . j  a  v a  2 s.  com*/
 */
public WebDriver initializeDriver(String sbrowser/*,String surl*/) {
    WebDriver driver = null;
    logger.info("Browser Name:" + sbrowser);
    //   logger.info(" Application surl:"+surl);
    if (driver == null) {
        if (sbrowser.equalsIgnoreCase("firefox")) {

            /*logger.info("The value of Path  is------------->"+System.getProperty("user.dir")+firebugPath);
            File firebug = new File(getFilePath(firebugPath));
            File firepath_new = new File(getFilePath(firepath));
             */
            //File netExport = new File(getFilePath(netExportPath));

            /*Capabilities cap =  dri.getCapabilities();
            String browserName = cap.getBrowserName().toLowerCase();
            System.out.println("Browser Name"+browserName);
            String os = cap.getPlatform().toString();
            System.out.println("operating system"+os);
            String v = cap.getVersion().toString();
            System.out.println("Version is"+v);
             *//*try {
                profile.addExtension(firebug);
                profile.addExtension(firepath_new);
                //profile.addExtension(netExport);
                } catch (IOException e) {
                e.printStackTrace();
                }
                */
            /*   profile.setPreference("app.update.enabled", false);
            profile.setPreference("extensions.firebug.currentVersion", "2.0");
            profile.setPreference("extensions.firebug.addonBarOpened", true);
            profile.setPreference("extensions.firebug.console.enableSites", true);
            profile.setPreference("extensions.firebug.script.enableSites", true);
            profile.setPreference("extensions.firebug.net.enableSites", true);
            profile.setPreference("extensions.firebug.previousPlacement", 1);
            profile.setPreference("extensions.firebug.allPagesActivation", "on");
            profile.setPreference("extensions.firebug.onByDefault", true);
            profile.setPreference("extensions.firebug.defaultPanelName", "net");
                    
            profile.setPreference(
               "extensions.firebug.netexport.alwaysEnableAutoExport", true);
            profile.setPreference("extensions.firebug.netexport.autoExportToFile",true);
            profile.setPreference("extensions.firebug.netexport.Automation", true);
            profile.setPreference("extensions.firebug.netexport.showPreview", false);
            logger.info("The path of the response folder is "+System.getProperty("user.dir")+"\\ResponseFolder\\");
                    
            profile.setPreference("extensions.firebug.netexport.defaultLogDir",getFilePath(responseFileDownloadpath));
             */
            //         FirefoxProfile profile = new FirefoxProfile();
            //profile.setEnableNativeEvents(true);
            //logger.info("enabled events are"+profile.areNativeEventsEnabled());
            /*         DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.setBrowserName(sbrowser);
            capabilities.setPlatform(org.openqa.selenium.Platform.ANY);
            capabilities.setCapability(FirefoxDriver.PROFILE, profile);
                    
             */
            System.setProperty("webdriver.gecko.driver", getFilePath(FIREFOXPATH));
            //String downloadPath = getFilePath(DOWNLOADSPATH);
            //   FirefoxProfile profile = new FirefoxProfile();
            /*profile.setPreference("browser.download.folderList", 2);
            profile.setPreference("browser.download.manager.showWhenStarting", false);
            profile.setPreference("browser.download.dir", downloadPath);
            profile.setPreference("browser.helperApps.neverAsk.openFile",
                  "text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml");
            profile.setPreference("browser.helperApps.neverAsk.saveToDisk",
            "text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml");
            profile.setPreference("browser.helperApps.alwaysAsk.force", false);
            profile.setPreference("browser.download.manager.alertOnEXEOpen", false);
            profile.setPreference("browser.download.manager.focusWhenStarting", false);
            profile.setPreference("browser.download.manager.useWindow", false);
            profile.setPreference("browser.download.manager.showAlertOnComplete", false);
            profile.setPreference("browser.download.manager.closeWhenDone", false);
            profile.setPreference("xpinstall.signatures.required", false);
            logger.info("The Profile Setup Data");*/

            driver = new FirefoxDriver();
            /*webdriver= new EventFiringWebDriver(driver);
            EventListerners eventListerners=new EventListerners();
            webdriver.register(eventListerners);
            */ String s = (String) ((JavascriptExecutor) driver).executeScript("return navigator.userAgent;");
            logger.info("Browser name : " + s);
        }

        else if (sbrowser.equalsIgnoreCase("Chrome")) {
            /*   logger.info("The Profile set up started @@@@@@@@@@@@@@@@@@@@@@@@@@@");
               System.setProperty("webdriver.chrome.driver", getFilePath(CHROMEPATH));
               HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
               chromePrefs.put("profile.default_content_settings.popups", 0);
               chromePrefs.put("download.default_directory",getFilePath(DOWNLOADSPATH));
               ChromeOptions options = new ChromeOptions();
               HashMap<String, Object> chromeOptionsMap = new HashMap<String, Object>();
               options.setExperimentalOption("prefs", chromePrefs);
               options.addArguments("--test-type");
               DesiredCapabilities cap = DesiredCapabilities.chrome();
               //cap.setCapability(ChromeOptions.CAPABILITY, chromeOptionsMap);
               cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
               cap.setCapability(ChromeOptions.CAPABILITY, options);
               logger.info("Initializing chrome webDriver");
               driver = new ChromeDriver(cap);
            */
            driver = new ChromeDriver(chromeProfileSetUp());
            //   logger.info("The Profile set up Ended #####################");

            //driver = new ChromeDriver(chromeProfileSetUp());
            /*    webdriver= new EventFiringWebDriver(driver);
                EventListerners eventListerners=new EventListerners();
                webdriver.register(eventListerners);
            */
            String s = (String) ((JavascriptExecutor) driver).executeScript("return navigator.userAgent;");
            System.out.println("Browser name : " + s.split("Chrome"));
            String[] result = s.split("Chrome");
            //      logger.info("Result value is"+result[1].substring(1,6));
            versionvalue = result[1].substring(1, 6);
            //   setVersionvalue(versionvalue);
        } else if (sbrowser.equalsIgnoreCase("IE")) {
            /*if (System.getProperty("os.arch").contains("86")) {
            logger.info("System is---"+System.getProperty("os.arch")+"---bit");
              System.setProperty("webdriver.ie.driver",
            getFilePath("/src/test/resources/Browsers_Binaries/IE/IEDriverServer64.exe"));
             } 
            else if (System.getProperty("os.arch").contains("64")) {
               logger.info("System is---"+System.getProperty("os.arch")+"---bit");
              System.setProperty("webdriver.ie.driver",
            getFilePath("/src/test/resources/Browsers_Binaries/IE/IEDriverServer64.exe"));
            }*/

            driver = new InternetExplorerDriver(ieProfileSetUp());
            /*             webdriver= new EventFiringWebDriver(driver);
                         EventListerners eventListerners=new EventListerners();
                         webdriver.register(eventListerners);
            */ } else if (sbrowser.equalsIgnoreCase("Safari")) {
            DesiredCapabilities capabilities = DesiredCapabilities.safari();
            driver = new SafariDriver(capabilities);
            /*             webdriver= new EventFiringWebDriver(driver);
                         EventListerners eventListerners=new EventListerners();
                         webdriver.register(eventListerners);
            */ }

    }
    driver.manage().timeouts().implicitlyWait(1, TimeUnit.MINUTES);
    return driver;
}

From source file:com.chorus.aceitacao.AbstractSeleniumChorusTest.java

License:Open Source License

@BeforeClass
public static void setUp() {
    driver = new FirefoxDriver();
    String server = "http://localhost:8081/chorus/";
    selenium = new WebDriverBackedSelenium(driver, server);
    driver.get(server);//from  ww w  .jav a 2  s .c  om
}

From source file:com.citrix.g2w.webdriver.tests.BaseWebDriverTest.java

License:Open Source License

/**
 * Method to create new WebDriver.//w w  w  .  j  ava2  s  . c  o  m
 * 
 * @return (driver object depends on input)
 */
protected WebDriver getWebDriver() {
    // Not handling any concurrency issues since expect single thread to run
    // TODO: Web driver creation for every page seems weird, should be a
    // webdriver per test. Move out web driver instantiation
    if (this.webDriver != null) {
        return this.webDriver;
    }
    String driver = this.propertyUtil.getProperty("driver");
    if ((driver != null) && (driver.equalsIgnoreCase("firefox"))) {
        this.webDriver = new FirefoxDriver();

    } else if (driver.equalsIgnoreCase("remotewebdriver")) {
        //Hardcoding to  firefox  
        DesiredCapabilities capability = DesiredCapabilities.firefox();
        try {
            this.webDriver = new RemoteWebDriver(
                    new URL("http://" + this.propertyUtil.getProperty("seleniumGridHost") + ":4444/wd/hub"),
                    capability);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    } else if (driver.equalsIgnoreCase("ghostdriver")) {
        // String path1 =
        // this.getClass().getResource("/test/phantomjs").getPath();
        String path = "D://Projects//WebinarProject//lib//phantomjs/ .exe";

        // Command line arguments to phantomjs
        ArrayList<String> cliArgsCap = new ArrayList<String>();
        cliArgsCap.add("--web-security=false");
        cliArgsCap.add("--ssl-protocol=any");
        cliArgsCap.add("--ignore-ssl-errors=true");

        DesiredCapabilities dCaps = new DesiredCapabilities();

        dCaps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgsCap);
        dCaps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, path);
        dCaps.setJavascriptEnabled(true);

        this.webDriver = new PhantomJSDriver(dCaps);
        this.webDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    } else {
        this.webDriver = new CustomHtmlUnitDriver(true, false);
        this.webDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    }

    return this.webDriver;
}

From source file:com.cloudbees.test.SeleniumTest.java

License:Apache License

@Test
public void testFirefoxDriver() throws Exception {
    System.err.println("");
    System.err.println("#############################");
    System.err.println("# INSTANTIATE FirefoxDriver");
    System.err.println("#############################");

    FirefoxDriver webDriver = new FirefoxDriver();
    testSeleniumDriver(webDriver);/* w  w  w .  j a  v a2 s  .c  o  m*/
}

From source file:com.codenvy.ide.automation.ImportProxyTest.java

License:Open Source License

@BeforeClass
public void openBrowser() throws InterruptedException {
    System.setProperty("webdriver.firefox.profile", "default");
    // Initialize web driver
    driver = new FirefoxDriver();
    /* Allows WebDriver to poll the DOM for a certain duration until the
     elements load*///from w  ww. ja v a2  s .c om
    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
    // Navigates to the web page
    driver.get(GWTIDConstants.WEB_APP_URL);
    //Initialize elements to be used
    importProxyObject = PageFactory.initElements(driver, ImportProxyObjects.class);
}

From source file:com.codenvy.ide.automation.ListBoxActionTest.java

License:Open Source License

@BeforeClass
public void openBrowser() throws InterruptedException {
    System.setProperty("webdriver.firefox.profile", "default");
    // Initialize web driver
    driver = new FirefoxDriver();
    // Allows WebDriver to poll the DOM for a certain duration until the
    // elements load
    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
    // Navigates to the web page
    driver.get(GWTIDConstants.WEB_APP_URL);
    // Initialize elements to be used
    newProxyObject = PageFactory.initElements(driver, NewProxyObjects.class);
}

From source file:com.codenvy.ide.automation.NewProxyCreationTest.java

License:Open Source License

@BeforeClass
public void openBrowser() throws InterruptedException {
    //TODO use try- catch, log and throw
    System.setProperty("webdriver.firefox.profile", "default");
    // Initialize web driver
    driver = new FirefoxDriver();
    // Allows WebDriver to poll the DOM for a certain duration until the
    // elements load

    //TODO use some event mechanism to identify dynamic load time without using a constant value
    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
    // Navigates to the web page
    driver.get(GWTIDConstants.WEB_APP_URL);
    // Initialize elements to be used
    newProxyObject = PageFactory.initElements(driver, NewProxyObjects.class);
}

From source file:com.codenvy.ide.test.UITestsRunner.java

License:Open Source License

@BeforeClass
public void openBrowser() throws InterruptedException {
    System.setProperty("webdriver.firefox.profile", "default");
    // Initialize web driver
    driver = new FirefoxDriver();
    // Allows WebDriver to poll the DOM for a certain duration until the
    // elements load
    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
    // Navigates to the web page
    driver.get(GWTIDConstants.WEB_APP_URL);
    // Initialize elements to be used
    aboutDialogOpen = PageFactory.initElements(driver, AboutDialogOpen.class);
    createNewProject = PageFactory.initElements(driver, NewWSO2AppServerProjectCreation.class);
}

From source file:com.continuuity.test.drivers.FireFox.java

License:Apache License

public WebDriver getDriver() {
    if (driver == null) {
        driver = new FirefoxDriver();
    }
    return driver;
}

From source file:com.conwet.silbops.EndToEndHTMLIT.java

License:Open Source License

@Before
public void setup() {

    System.out.println("*** Setting up environment...");
    baseUrl = "http://localhost:" + getServerPort() + "/";
    fakeClient = new FakeClient();
    System.out.println("connecting " + fakeClient.getClass().getSimpleName() + " to broker...");
    fakeClient.connect();/* w  ww.  ja v  a  2  s .  co m*/
    System.out.print("creating new FirefoxDriver...");
    browser = new FirefoxDriver();
    System.out.println("done.");
}