0

In my program, We are creating selenium webdriver for firefox with linux operating system. I wanted to know if there is any way you can create the driver which will initalize for the default operating system and web browser.

   protected static WebDriver driver = init();



private static WebDriver init()
   {
      DesiredCapabilities capability = DesiredCapabilities.firefox(); // I want 
to detect the default browser of OS
      capability.setPlatform(Platform.LINUX);//it should automatically find the OS.

  WebDriver driver = init(BrowserType.FIREFOX);//Same here for initializing default web browser.

  driver.manage()
        .deleteAllCookies();
  driver.manage()
        .timeouts()
        .pageLoadTimeout(50, TimeUnit.SECONDS);
  driver.manage()
        .timeouts()
        .implicitlyWait(10, TimeUnit.SECONDS);
  driver.manage()
        .window()
        .maximize();
  return driver;

}

Ashish
  • 14,295
  • 21
  • 82
  • 127
  • Are you asking this http://stackoverflow.com/questions/15852885/ question or something different? – SiKing Jan 29 '14 at 22:57

1 Answers1

0

To the best of my knowledge, the following options work on both Windows and Linux:

Option #1 - open in Normal mode:

WebDriver webDriver = new FirefoxDriver();

Option #1 - open in Headless mode:

FirefoxBinary binary = new FirefoxBinary(new File("your/firefox/path"));
binary.setEnvironmentProperty("DISPLAY",System.getProperty("lmportal.xvfb.id",":99"));
WebDriver webDriver = new FirefoxDriver(binary,null);
barak manos
  • 29,648
  • 10
  • 62
  • 114