Change IE9 to IE8 with Selenium WebDriver in Ruby

ie-developer-tools, internet-explorer, ruby, selenium, webdriver

Solution

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.

Problem

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.

Original source