How to Launch Browser in Selenium

How to Launch Chrome Browser In Selenium

First Method

import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;

public class LaunchBrowser {

 public static void main(String[] args){

System.setProperty("webdriver.chrome.driver","C:\\Users\\nitis\\Downloads\\chromedriver\\chromedriver.exe");       
 
WebDriver driver=new ChromeDriver();

    }
}

Second method

import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;

public class LaunchBrowser {

 public static void main(String[] args){

     WebDriverManager.chromedriver().setup();
     WebDriver driver=new ChromeDriver();

    }
}

Leave a Comment