We can also run the Selenium Webdriver programs in Internet Explorer web browser to perform automation testing.
To run the Selenium Webdriver programs in Internet Explorer web browser we need to download IE Driver
Here is the very basic program to run Selenium Webdriver programs in Internet Explorer web browser.
Detailed explanation for the above program is as follows:
Following code is the required package for Java File.
Following code is the required packages for Selenium Webdriver.
Following code is the required packages for IE driver.
Following code is to initialize the webdriver.
Following code is to locate the ie driver executable file.
Following code is to set the ie driver with webdriver property.
Following code is to initialize the ie driver.
Following code is to open the hello selenium blog in ie browser.
You can also use the following code is to open the hello selenium blog in browser.
Following code is to quit the driver instance.
You can also use the following code is to close the driver instance.
To run the Selenium Webdriver programs in Internet Explorer web browser we need to download IE Driver
Here is the very basic program to run Selenium Webdriver programs in Internet Explorer web browser.
Java Source code:
package com.helloselenium.selenium.test; import java.io.File; import org.openqa.selenium.WebDriver; import org.openqa.selenium.ie.InternetExplorerDriver; public class OpenHelloSeleniumBlogInInternetExplorer{ public static void main(String[] args) { WebDriver driver = null; File IEDriver = new File("path of the IEDriverServer (.exe file)"); System.setProperty("webdriver.ie.driver", IEDriver.getAbsolutePath() ); driver = new InternetExplorerDriver(); driver.get("http://helloselenium.blogspot.com"); driver.quit(); } }
Detailed explanation for the above program is as follows:
Following code is the required package for Java File.
import java.io.File;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
WebDriver driver = null;
File IEDriver = new File("path of the IEDriverServer (.exe file)");
System.setProperty("webdriver.ie.driver", IEDriver.getAbsolutePath() );
Following code is to initialize the ie driver.
driver = new InternetExplorerDriver();
driver.get("http://helloselenium.blogspot.com");
driver.navigate().to("http://helloselenium.blogspot.com");
driver.quit();
driver.close();
1 Comments
I am getting below error when i launch IE.
ReplyDeleteStarted InternetExplorerDriver server (64-bit)
3.5.0.0
Listening on port 32927
Only local connections are allowed
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: 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.
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'SEIODC175', ip: '172.16.30.26', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_144'
Driver info: driver.version: InternetExplorerDriver
remote stacktrace:
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.W3CHandshakeResponse.lambda$new$0(W3CHandshakeResponse.java:57)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction$2(W3CHandshakeResponse.java:104)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$24(ProtocolHandshake.java:360)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:363)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:137)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:641)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:254)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:205)
at org.openqa.selenium.ie.InternetExplorerDriver.(InternetExplorerDriver.java:197)
at org.openqa.selenium.ie.InternetExplorerDriver.(InternetExplorerDriver.java:152)
at IEBrowser.IEBrowserExecution.main(IEBrowserExecution.java:16)
What would you like to add in my list? I look forward to reading your comments below.