使用Ruby中的Selenium WebDriver将IE9更改为IE8

使用Ruby中的Selenium WebDriver将IE9更改为IE8

问题描述:

我正在将Selenium WebDriver与Ruby结合使用,并试图创建一个将在IE8中进行测试的脚本.我无法找到有关如何将iedriver设置为以IE8模式启动或在webdriver启动后如何将其切换为IE8的答案.我在Windows 7上,因此只有IE9可用.我当前用于在IE9中启动Webdriver的代码是

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.

如果要在运行时告诉IE版本,可以使用DesiredCapabilities.

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);

有关DesiredCapabilities的更多信息,请使用此链接 http://code.google. com/p/selenium/wiki/DesiredCapabilities .

For more info about DesiredCapabilities use this link http://code.google.com/p/selenium/wiki/DesiredCapabilities.

在评论中您说我同时需要IE 8和IE8.实际上是不可能的,Windows当前仅支持在一个盒子中安装一个IE版本. IEDriver使用已安装的IE版本启动.

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.

如果要使用IE的多个版本进行测试,则更好的选择与Windows Virtual Machines一起使用.您可以使用RemoteWebdriver实例与虚拟机对话.

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.