We saw earlier that; Selenium WebDriver supports various programming languages and various web browsers for testing. Selenium WebDriver supports various browsers like IE, Firefox, Google Chrome, Opera.
It can also be used on Android & iOS. Selenium WebDriver can support all operating systems where these browsers can run.
Majorly people use Mozilla Firefox. In order to use Mozilla Firefox, we do not need to do any special configurations, but for using other browsers like Chrome and IE, we need to set system properties.
Let us talk one by one.
How to use Mozilla Firefox browser using selenium?
For using Mozilla Firefox in Selenium Webdriver, we do not need any configurations setup.
Just create a reference variable of the WebDriver instance and assign it to the instance of FiirefoxDriver class.
So, below line of code will launch Firefox web browser.
WebDriver driver = new FirefoxDriver();
Now, you can use “driver” instance for further process like navigating to URL and proceed with your testing.
To know more about Interface and to understand Why do we write WebDriver driver = new FirefoxDriver() ?, refer below post
How to use Google Chrome browser using selenium?
In order to use Google Chrome for executing test cases, we need to set system property for “Webdriver.chrome.driver” with executable file of chrome driver (chromedriver.exe).
Once the chromedriver.exe file is downloaded, set system properties as –
System.setProperty("webdriver.chrome.driver", "C:chromedriver.exe");
(assuming that it is stored at C drive, else provide your file location).
Now, once system property is set, we can launch chrome browser using below line of code –
WebDriver driver = new ChromeDriver();
Now, you can use “driver” instance for further process like navigating to URL and proceed with your testing.
How to use Internet Explorer browser using selenium?
In order to use Internet Explorer for executing test cases, again, as like we did for google chrome, we need to set system property for “Webdriver.ie.driver” with executable file of IEDriverServer. (IEDriverServer.exe).
Once the IEDriverServer.exe file is downloaded, set system properties as –
System.setProperty("webdriver.ie.driver", "C:IEDriverServer.exe");
(assuming that it is stored at C drive, else provide your file location).
Now, once system property is set, we can launch chrome browser using below line of code –
WebDriver driver = new InternetExplorerDriver();
Now, you can use “driver” instance for further process like navigating to URL and proceed with your testing.
Hope this helps. Drop your comments.