Using the InternetExplorerDriver for WebDriver
Please refer Blog Entry
How do I start the Internet Explorer WebDriver for Selenium ?
Problem:
We want to run our test cases on Internet Explorer browser using selenium WebDriver.
Solution:
Lets Try to do it same as we did for FireFox browser.
import org.openqa.selenium.WebDriver; import org.openqa.selenium.ie.InternetExplorerDriver; public class IEtestforDesiredCapabilities { public static void main(String[] args) { WebDriver driver = new InternetExplorerDriver(); driver.manage().window().maximize(); driver.get("http://google.com"); driver.quit(); } }
Now run this code from Eclipse. And check out the console.
It will thrown Error
The path to the driver executable must be set by the webdriver.ie.driver system property; for more information, see http://code.google.com/p/selenium/wiki/InternetExplorerDriver. The latest version can be downloaded from http://code.google.com/p/selenium/downloads/list Dec 11, 2012 12:59:43 PM org.openqa.selenium.ie.InternetExplorerDriverServer initializeLib WARNING: This method of starting the IE driver is deprecated and will be removed in selenium 2.26. Please download the IEDriverServer.exe from http://code.google.com/p/selenium/downloads/list and ensure that it is in your PATH. Exception in thread "main" org.openqa.selenium.WebDriverException: 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) Command duration or timeout: 1.21 seconds Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:09:54' System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_05' Driver info: driver.version: InternetExplorerDriver Session ID: b0f78d3b-1ed2-4ace-ba9b-4c4063cf871b at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:498) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:182) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:167) at org.openqa.selenium.ie.InternetExplorerDriver.startSession(InternetExplorerDriver.java:133) at org.openqa.selenium.ie.InternetExplorerDriver.setup(InternetExplorerDriver.java:106) at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:52) at IEtestforDesiredCapabilities.main(IEtestforDesiredCapabilities.java:12)
So we have one question in our mind……
How can we do this ? How can we set this programmatically?
The solution is give in that error.
Download InternetExplorerDriver standalone server for 32-bit IE OR InternetExplorerDriver standalone server for 64-bit IE
And put this IEDriverServer.exe to appropriate drive. We put in C:/ drive in this example
Now few more things to know which we are going to resolve this issue
Class DesiredCapabilities and method of this class internetExplorer()
setCapability
System.setProperty
InternetExplorerDriver(capabilities)
import org.openqa.selenium.WebDriver; import org.openqa.selenium.ie.InternetExplorerDriver; import org.openqa.selenium.remote.DesiredCapabilities; public class IEtestforDesiredCapabilities { public static void main(String[] args) { // Method and Description - static DesiredCapabilities internetExplorer() DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); //Method and Description - void setCapability(java.lang.String capabilityName, boolean value) capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); //Among the facilities provided by the System class are standard input, standard output, and error output streams; access to externally defined "properties"; a means of loading files and libraries; and a utility method for quickly copying a portion of an array. System.setProperty("webdriver.ie.driver", "C:\\IEDriverServer.exe"); //InternetExplorerDriver(Capabilities capabilities) WebDriver driver = new InternetExplorerDriver(capabilities); driver.manage().window().maximize(); driver.get("http://google.com"); driver.quit(); } }
The END
Introduction and overview of other Implementing Classes of WebDriver Interface AndroidDriver, ChromeDriver, FirefoxDriver, HtmlUnitDriver, InternetExplorerDriver, IPhoneDriver
Introduction and overview of other Implementing Classes of WebDriver Interface
AndroidDriver, ChromeDriver, FirefoxDriver, HtmlUnitDriver, InternetExplorerDriver, IPhoneDriver
FirefoxDriver
http://tinyurl.com/cmz4nwe
http://tinyurl.com/7zcey6o
HtmlUnitDriver – This is currently the fastest and most lightweight implementation of WebDriver.
http://tinyurl.com/cje4fgd
http://tinyurl.com/ce2yd9q
InternetExplorerDriver – This class is provided as a convenience for easily testing the InternetExplorer browser. The InternetExplorerDriver is a standalone server which implements WebDriver’s wire protocol. This driver has been tested with IE 6, 7, 8 and 9 on appropriate combinations of XP, Vista and Windows 7.
http://tinyurl.com/d8euuka
http://tinyurl.com/6qvwlka
ChromeDriver – This class is provided as a convenience for easily testing the Chrome browser.
http://tinyurl.com/5s7zown
http://tinyurl.com/d9wb2py
AndroidDriver – Android WebDriver allows to run automated end-to-end tests that ensure your site works correctly when viewed from the Android browser.
http://tinyurl.com/72wb7j4
http://tinyurl.com/bl9wz5t
IPhoneDriver – The iphone driver allows testing on a UIWebView (a webkit browser accessible for 3rd party applications) on the iphone. It works through the use of an iphone application running on your iphone, ipod touch or iphone simulator.
http://tinyurl.com/ckh7axr
http://tinyurl.com/7828449
Lets set up environment before move forward
Lets set up environment before move forward
Java SE Development Kit 7 Downloads
Take it
Eclipse
Take it
Selenium RC Server
Take it
flash-selenium
Take it
silverlight-selenium
Take it
Grid 2
VMware Workstation
Take it
Selenium WebDriver
Take it
InternetExplorerDriver
32 bit Windows IE
• Lets Open First FireFox browser using FirefoxDriver
import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class FirstProgramOfSelenium { public static void main(String[] args) { //Open Firefox browser WebDriver driverFireFox = new FirefoxDriver(); WebDriver driverFireFox1 = new FirefoxDriver(); WebDriver driverFireFox2 = new FirefoxDriver(); // Open URL in browser driverFireFox.get("http://seleniumhq.org"); driverFireFox1.get("http://www.linkedin.com/"); driverFireFox2.get("http://wordpress.com/"); } }
What is Javadocs and how to use it?
1. Go to http://seleniumhq.org/download/
2. Click on JavaDocs link http://selenium.googlecode.com/svn/trunk/docs/api/java/index.html
3. This contains lots of class, interfaces, methods
4. Search for Webdriver interface
5. All Interfaces are italic text
6. Open webdriver interface [http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebDriver.html]
7. Walkthrough All Known Implementing Classes
How to download Selenium-WebDriver jar? How to Setting Up a Selenium-WebDriver Project into Eclipse?
How to download Selenium-WebDriver jar?
How to Setting Up a Selenium-WebDriver Project into Eclipse?
- Go to google.com
- Type download selenium webdriver
- Click on the link seleniumhq.org/download/
- Go to Selenium Client Drivers section
- Click on latest release of JAVA download link Link
- Wait till downloading
- Once it is downloaded unzip files to specific drive
How do I add an extra library (.jar)[Selenium WebDriver] to my project’s classpath?
Open Eclipse.
Create new project.
Create new folder name Lib.
Right click and go to configure Build Path
Now go to Java Build Path > Libraries Tab > Click on Add External JARs.
Browse to selenium jars location
For More reference Link 1
You must be logged in to post a comment.