Selenium WebDriver is a tool to automate manual testcases. Selenium
is open source tool for automating web applications. The latest version
of selenium is Selenium3.0 . Selenium tests can be run against most
modern browsers such as Firefox, Chrome and Internet Explorer. Selenium
can be deployed on Windows, Linux and Mac.
Working with Browsers :
1. Open Firefox Browser :
Webdriver has FirefoxDriver class to open a new session of firefox browser.
Syntax :
// Need to import following packages
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
//Instance of FirefoxDriver
WebDriver ffDriver = new FirefoxDriver();
//Open google.com site
ffDriver.get("http://www.google.com") ;
2. Open Chrome Browser :
Webdriver has ChromeDriver class to open a new session of chrome browser. To use chrome driver we need to download and provide path of ChromeDriver.exe. We can set the path using System.setProperty();
Syntax :
// Need to import following packages
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
//Instance of ChromeDriver
System.setProperty("webdriver.chrome.driver", "Path Of ChromeDriver.exe");
WebDriver chDriver = new ChromeDriver();
//Open google.com site
chDriver.get("http://www.google.com") ;
3. Open InternetExplorer Browser :
Webdriver has InternetExplorer class to open a new session of InternetExplorer browser. To use InternetExplorer driver we need to download and provide path of InternetExplorerDriver.exe. We can set the path using System.setProperty();
Syntax :
// Need to import following packages
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.internetexplorer.InternetExplorerDriver;
//Instance of InternetExplorerDriver
System.setProperty("webdriver.ie.driver", "Path Of InternetExplorerDriver.exe");
WebDriver ieDriver = new InternetExplorerDriver();
//Open google.com site
ieDriver.get("http://www.google.com") ;
Working with Browsers :
1. Open Firefox Browser :
Webdriver has FirefoxDriver class to open a new session of firefox browser.
Syntax :
// Need to import following packages
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
//Instance of FirefoxDriver
WebDriver ffDriver = new FirefoxDriver();
//Open google.com site
ffDriver.get("http://www.google.com") ;
2. Open Chrome Browser :
Webdriver has ChromeDriver class to open a new session of chrome browser. To use chrome driver we need to download and provide path of ChromeDriver.exe. We can set the path using System.setProperty();
Syntax :
// Need to import following packages
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
//Instance of ChromeDriver
System.setProperty("webdriver.chrome.driver", "Path Of ChromeDriver.exe");
WebDriver chDriver = new ChromeDriver();
//Open google.com site
chDriver.get("http://www.google.com") ;
3. Open InternetExplorer Browser :
Webdriver has InternetExplorer class to open a new session of InternetExplorer browser. To use InternetExplorer driver we need to download and provide path of InternetExplorerDriver.exe. We can set the path using System.setProperty();
Syntax :
// Need to import following packages
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.internetexplorer.InternetExplorerDriver;
//Instance of InternetExplorerDriver
System.setProperty("webdriver.ie.driver", "Path Of InternetExplorerDriver.exe");
WebDriver ieDriver = new InternetExplorerDriver();
//Open google.com site
ieDriver.get("http://www.google.com") ;