just wondering how I can instantiate different versions of InternetExplorerDriver.
That's how I can create a IE driver:
WebDriver ieWebDriver = new InternetExplorerDriver();
but I am not able to differentiate between IE6, IE7, IE8 and IE9.
Cheers,
Yes, you can. DesiredCapabilities have a public method which you can use:
this.SetCapability(CapabilityType.BrowserName, "internet explorer");
this.SetCapability(CapabilityType.Version, "8");
this.SetCapability(CapabilityType.Platform, "WINDOWS");
I've written extension methods to make it easier to instantiate any version by this call:
DesiredCapabilities internetExplorer8 =
DesiredCapabilities.InternetExplorer().SetVersion("8");
IWebDriver webDriver = new RemoteWebDriver(seleniumHubUrl, internetExplorer8);
This really makes sense if you use RemoteWebDriver and have a Selenium2 Grid/Hub set up with multiple nodes, e.g. multiple virtual machines each having a different version of Internet Explorer and each being a node connected to the hub.
And the extension:
public static class DesiredCapabilitiesExtension
{
public static DesiredCapabilities SetBrowserName(this DesiredCapabilities desiredCapabilities, string browserName)
{
// make sure the browser name is lowercase
desiredCapabilities.SetCapability(CapabilityType.BrowserName, browserName.ToLowerInvariant());
return desiredCapabilities;
}
public static DesiredCapabilities SetVersion(this DesiredCapabilities desiredCapabilities, string version)
{
desiredCapabilities.SetCapability(CapabilityType.Version, version);
return desiredCapabilities;
}
public static DesiredCapabilities SetPlatform(this DesiredCapabilities desiredCapabilities, string platform)
{
// make sure the platform is case sensitive, uppercase to make it work
desiredCapabilities.SetCapability(CapabilityType.Platform, platform.ToUpperInvariant());
return desiredCapabilities;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With