Internet Explorer Webdriver
Selenium webdriver provides cross browser support thus comes with driver package to run tests on Internet Explorer. Internet explorer webdriver is very complex to use and sometimes can be big pain area. However, we can improve Internet explorer performance by using appropriate capabilities for webdriver.Before we proceed further to Internet explorer capabilities we must know how to initialize Internet Explorer webdriver?
First Step would be to download the IEDriverServer for using Internet Explorer driver. without IEDriverServer the Internet explorer driver will not work properly. We can download the IEDriverServer file from this location for both 32 bit and 64 bit OS version. Next is to place this file either in your project path or you can place file at other location and use below code to use IEDriverServer file. Finally, use below code to initialize the Internet Explorer driver.
File file =null;
if (new File("C:\\Program Files (x86)").exists())
{
file = new File( "C:\\IEDriverServer_X64.exe");
}else
{
file = new File( "C:\\IEDriverServer_X86.exe");
}
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
WebDriver driver = new InternetExplorerDriver(dc);
Internet Explorer Capabilities
Internet explorer driver supports some important capabilities which can
be used to smooth execution of test on Internet Explorer. Some of these
capabilities help us to unable java scripts, ignore the security domain
setting for IE , Persistent hovering , require window focus etc... These
capabilities ease the way the for automation using selenium webdriver
on Internet explorer. More details on the Internet explorer can be
found here. Below code will guide on how to use the desired capabilities for Internet Explorer driver.
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING,false);
dc.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, false);
dc.setCapability(InternetExplorerDriver.UNEXPECTED_ALERT_BEHAVIOR, true);
dc.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
dc.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
dc.setJavascriptEnabled(true);
WebDriver driver = new InternetExplorerDriver(dc);
Above code will initiate Internet Explorer Driver with the capabilities.This will solve most of the problems with Internet explorer driver. It will be easier to handle to the Internet explorer issues. Some important capabilities of Internet Explorer webdriver are as follows:
ignoreProtectedModeSettings : Whether to skip the protected mode check. If set, tests may become flaky, unresponsive, or browsers may hang. If not set, and protected mode settings are not the same for all zones, an exception will be thrown on driver construction. Only "best effort" support is provided when using this capability.
ignoreZoomSetting : Indicates whether to skip the check that the browser's zoom level is set to 100%. Value is set to false by default.
enablePersistentHover : Determines whether persistent hovering is enabled (true by default). Persistent hovering is achieved by continuously firing mouse over events at the last location the mouse cursor has been moved to.
requireWindowFocus : Determines whether to require that the IE window have focus before performing any user interaction operations (mouse or keyboard events). This capability is false by default, but delivers much more accurate native events interactions.
Post a Comment
Post a Comment