Skip to main content

SELENIUM - Launching IE, Chrome, Firefox Browsers

Launching IE, Chrome, Firefox Browsers

  • Launching IE, Chrome, Firefox Browsers with Selenium WebDriver

public class LaunchingBrowsers{

 public static String str = "Chrome"; //change to IE and Firefox

 public static void main(String args[]) throws InterruptedException
 {

  System.setProperty("webdriver.chrome.driver" , "C:\\Selenium_Projects\\Geo_Driver\\chromedriver.exe");
  System.setProperty("webdriver.ie.driver","C:\\Selenium_Projects\\Geo_Driver\\IEDriverServer.exe");
  System.setProperty(GeckoDriverService.GECKO_DRIVER_EXE_PROPERTY,"C:\\Selenium_Projects\\Geo_Driver\\geckodriver.exe");

  WebDriver driver=null;

  if(str.equals("Chrome"))
  {
   //System.out.println("uma");
    driver= new ChromeDriver();
  }
  else if (str.equals("IE"))
  {
   driver = new InternetExplorerDriver();
  }
  else if (str.equals("FireFox"))
  {
      DesiredCapabilities capabilities = DesiredCapabilities.firefox();
      //capabilities.setCapability("firefox_binary","C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
      capabilities.setCapability("platform", "WIN10");
      capabilities.setCapability("version", "53.0");
      capabilities.setCapability("marionette", true);
      capabilities.setCapability("acceptSslCerts", true);
      driver = new FirefoxDriver(capabilities);
  }
  driver.get("http://www.guru99.com");
  driver.close();

 }
}

Comments