我所有的测试都在一个 ubuntu 盒子里运行。测试是用 PHP 编写的。它们可以与 Firefox 驱动程序和 chrome 驱动程序一起正常工作。我正在使用在同一个盒子中运行的独立 selenium 服务器(selenium-server-standalone-2.25.0.jar)。最近我需要针对 IE 平台编写测试。我已经尝试了一些事情,但到目前为止,我仍然不确定为我的特定场景设置 IE 驱动程序的正确方法是什么。
我尝试在同一个 ubuntu 框中安装带有 mono 的 IE,但在安装过程中遇到了很多问题,在我解决了这些问题并使其可以从命令行运行 IE 之后,它仍然没有为我的测试工作。
我在这里阅读了这个特定的文档:http://code.google.com/p/selenium/wiki/InternetExplorerDriver然后在一个窗口框上进行,直到我看到这个:
The HTTP server started by the IEDriverServer.exe sets an access control list to only accept connections from the local machine, and disallows incoming connections from remote machines. At present, this cannot be changed without modifying the source code to the IEDriverServer.exe. To run the Internet Explorer driver on a remote machine, use the Java standalone remote server in connection with your language binding's equivalent of RemoteWebDriver.
所以我将 selenium-server-standalone-2.25.0.jar 下载到 windows 机器并启动它;我的 IEDriverServer.exe 被放入了我的 PATH 中的 C:\windows\system32\。然后我将 ubuntu 框中的代码更改为指向在 windows 框上运行的 selenium 服务器。但仍然没有运气。
我用谷歌搜索了一下,有些人成功地让它运行起来了。但他们似乎正在使用 java 绑定(bind)或 c# 绑定(bind),我想他们是在本地机器上开发的。我还没有找到像我这样的工作案例:
a ubuntu box where PHP based tests run connection to a remote selenium server running on windows. a windows box with a selenium standalone server running and with IEDriverServer.exe in PATH
谢谢。
最佳答案
我有一个类似的问题 - 在 Linux 上工作并希望针对 IE 11 运行我的 WD 测试 - 并让它工作。我和 OP 的主要区别在于我的测试是用 Java 编写的。
我的目标是这样的:
我做了什么:
- The IEDriverServer executable must be downloaded and placed in your PATH.
- On IE 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. The value can be on or off, as long as it is the same for every zone. To set the Protected Mode settings, choose "Internet Options..." from the Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode".
- Additionally, "Enhanced Protected Mode" must be disabled for IE 10 and higher. This option is found in the Advanced tab of the Internet Options dialog.
- The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.
- For IE 11 only, you will need to set a registry entry on the target computer so that the driver can maintain a connection to the instance of Internet Explorer it creates. For 32-bit Windows installations, the key you must examine in the registry editor is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. For 64-bit Windows installations, the key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. Please note that the FEATURE_BFCACHE subkey may or may not be present, and should be created if it is not present. Important: Inside this key, create a DWORD value named iexplore.exe with the value of 0.
注意我不需要把
IEDriverServer.exe
的位置在 PATH 中,并且在我的 IE 11 设置中找不到“增强保护模式”(所以没有这样做)。java -jar selenium-server-standalone-2.53.1.jar
IEDriverServer.exe
RemoteWebDriver
,就像这样(192.168.56.101 是 Windows 框的 Host Only 网络 IP):DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
driver = new RemoteWebDriver(new URL("http://192.168.56.101:4444/wd/hub"),
capability);
mvn test myproject
它奏效了! :)
关于internet-explorer - 如何在远程机器上设置 IE webdriver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12380454/