Selenium 4 with Java
 Chrome Driver: import  org.openqa.selenium.WebDriver; import  org.openqa.selenium.firefox.FirefoxDriver; System. setProperty ( "webdriver.chrome.driver" , "C:\\libs\\drivers\\chromedriver.exe" ); WebDriver driver  = new  ChromeDriver(); Gecko Driver: System. setProperty ( "webdriver.gecko.driver" , "C:\\libs\\drivers\\geckodriver.exe" ); WebDriver driver  = new  FirefoxDriver(); Set Drivers in system path: Note : If your browser is upgraded, you have to download a compatible  browser driver and copy it to the directory which you added to the path  environment variable