I am using Selenium WebDriver with Ruby and am attempting to create a script that will test in IE8. I am unable to find an answer on how to set iedriver to launch in IE8 mode or how to switch it to IE8 after webdriver has launched. I am on Windows 7 so I only have IE9 available to me. The code I am currently using to launch webdriver in IE9 is
$driver = Selenium::WebDriver.for :ie
Any help would be greatly appreciated. I have looked high and low but cannot find any sort of answer to this question. If you need additional info from me I will happily provide it. Thank you very much.
If you want to tell the IE version during run time, you can use DesiredCapabilities.
DesiredCapabilities ieCapabilities = null;
ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setBrowserName("internet explorer");
ieCapabilities.setVersion("Version Number");
driver = new InternetExplorerDriver(ieCapabilities);
For more info about DesiredCapabilities
use this link http://code.google.com/p/selenium/wiki/DesiredCapabilities.
In the comments you said that i need both IE 8 and 9. Actually it is not possible, Windows currently supports to install only one IE version in a box. The IEDriver used the installed version of IE to launch.
If you want to use multiple version of IE to test then the better option to go with Windows Virtual Machines
. You can talk with virtual machines by using the RemoteWebdriver
instances.
Actually, this is currently not supported by Selenium WebDriver. There is currently an enhancement request for the IE modes to be implemented as a part of the DesiredCapabilities functionality referenced in the comment from Manigandan.
You can follow this enhancement request here: http://code.google.com/p/selenium/issues/detail?id=2564
Other possible solutions mentioned on the enhancement request is manipulating the FEATURE_BROWSER_EMULATION registry key (see http://msdn.microsoft.com/en-us/library/ee330730(v=vs.85).aspx ) or using keyboard commands to open Developer Tools and selecting the mode from there (I am not sure how well this solution would work, as the workaround in Python requires the WebDriver object to be cast as a Selenium 1.0 object).
来源:https://stackoverflow.com/questions/14466538/change-ie9-to-ie8-with-selenium-webdriver-in-ruby