

Lets us now execute below example program using TestNG.

In the same way, if we want to work with other browsers, we will import statements accordingly like 'import .FirefoxDriver' for firefox and 'import .InternetExplorerDriver' for InternetExplorer. As we are working with chrome browser, we have imported '.ChromeDriver'. In the above program, we have imported two statements which allows us to access classes from selenium webdriver packages. tProperty("", driverPath+"chromedriver.exe") īelow image shows the class 'ChromeExample.java' and to run as java application. Public static String driverPath = "F:/lib/chromedriver/" To run the below program Right Click -> Run As -> Java Application. Let us try to run a simple example to Open Google Chrome using Selenium with Java. Next, we need to instantiate an instance of ChromeDriver, which will be driving our browser: driver = webdriver.Chrome() If you dint set the path / or if you give the wrong path, then you will be seeing below error immediately once you start your scriptĮrror: The path to the driver executable must be set by the system property In your code you need to set the property for chrome driver, specify its location via the as below tProperty("", "pathofchromedriver\\chromedriver.exe")

Save the downloaded file to your local machine.

If you are working on windows environment, you need to click on "Chromedriver_win32.zip". Note: Choose the chromedriver based on your working environment. You can download latest version of ChromeDriver server from Download Chrome Server ChromeDriver is supported by the Chromium team, ChromeDriver is a standalone server which implements WebDriver's wire protocol for Chromium.įirst of all, download latest version of ChromeDriver server for webdriver. Now to run selenium webdriver in Chrome browser, we need to take the help of ChromeDriver which is a separate executable that selenium webdriver uses to control chrome. exe path of the driver server for the individual browsers. Selenium supports to run webdriver in other browsers by just adding an. Then the next question come to your mind is How to run webdriver in other browsers. Selenium 2 by-default supports Mozilla Firefox browser. Normally to run webdriver, we just need a browser and a selenium server jar file.
