How to Launch Browser in Selenium

Launching firefox browser using Geckodriver


Step-1 first Download geckodriver.exe from GeckoDriver Github Release Page.

Step-2 second  Set the System Property for
 ("webdriver.gecko.driver" )
with the geckodriver.exe path - System.setProperty
("webdriver.gecko.driver","geckodriver.exe path");

Real Time Example

public class FirefoxBrowserLaunching {

    public static void main(String[] args) {

      System.setProperty("webdriver.gecko.driver", pathToGeckoDriver + "\\geckodriver.exe");
  
      WebDriver driver = new FirefoxDriver();   
    
       driver.get("http://qaacharya.com ");
}
}


 Launching Chrome Browser in Selenium

Real Time Example

public class FirefoxBrowserLaunching {

  public static void main(String[] args) {

System. setProperty("webdriver.chrome.driver", "path of the exe file\\chromedriver.exe");   

   WebDriver driver = new ChromeDriver();    
   
   driver.get("http:// qaacharya.com ");
}

}










































































QA Acharya