FirefoxDriver, OperaDriver,SafariDriver,ChromeDriver,InternetExplorerDriver are all classes which can implement Webdriver interface.
Here's how one can instantiate webdriver for the browsers supported by selenium webdriver.
FireFox
WebDriver driver = new FirefoxDriver();
Opera
WebDriver driver = new OperaDriver();
Safari
WebDriver driver = new SafariDriver();
Internet Explorer
I downloaded IEDriver 32 bit version for windows from the link mentioned below, and I pasted the downloaded file into my machine's D drive.
http://selenium-release.storage.googleapis.com/index.html?path=2.44/
Secondly, we need to do the following
In IE browser window, go to Internet Options and under Security tab,for each of the zones, Internet,Local intranet,Trusted sites,Restricted sites,either check or uncheck, Enable Protected Mode checkbox
If protected mode is not set to the same in all regions, then the following exception occurs :
Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)
So once this is done, we need to specify the path to the IE driver binary in our code as mentioned below,
System.setProperty("webdriver.ie.driver","D:\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
Chrome
I downloaded chromedriver 32 bit version for windows from the link mentioned below, and I pasted the downloaded file into my machine's D drive.
http://chromedriver.storage.googleapis.com/index.html?path=2.10/
So once this is done, we need to specify the path to the chrome driver binary as mentioned below,
WebDriver driver = new ChromeDriver();
Note:
HTMLUnitDriver is a headless browser implementation and is currently the fastest and most lightweight implementation of WebDriver.
It can be implemented as below,
WebDriver driver = new HtmlUnitDriver();
Pay It Forward...
Lots of energy ..
DR
No comments:
Post a Comment