IE11上的Selenium WebDriver

时间:2014-05-21 12:15:47

标签: internet-explorer selenium internet-explorer-11

我正在使用WebDriver自动化我们的webapp的回归套件,我试图让我的测试脚本与IE11一起运行,但没有取得任何成功。

我了解IEDriverServer.exe目前不支持WebDriver,问题需要Microsoft的合作,我已经尝试了对Selenium问题#6511的回复中概述的步骤。

  1. (仅对于IE 11,您需要在目标计算机上设置一个注册表项,以便驱动程序可以维护与其创建的Internet Explorer实例的连接。对于32位Windows安装,密钥您必须在注册表编辑器中检查HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Internet Explorer \ Main \ FeatureControl \ FEATURE_BFCACHE。

    对于64位Windows安装,密钥为HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \ Microsoft \ Internet Explorer \ Main \ FeatureControl \ FEATURE_BFCACHE。请注意,FEATURE_BFCACHE子项可能存在也可能不存在,如果不存在,则应创建该子项。在此键内,创建一个名为iexplore.exe的值为0的DWORD值。)

  2. 所有区域的保护模式设置相同

  3. 已禁用增强保护模式。

  4. 但是当我在IE11中执行我的自动化脚本时,它正在打开浏览器并且低于Exception

    org.openqa.selenium.ElementNotVisibleException: Received a JavaScript error attempting to 
    click on the element using synthetic events.We are assuming this is because the element 
    isn't displayed, but it may be due to other problems with executing JavaScript. (WARNING:
    The server did not provide any stacktrace
    information)
    

    任何人都可以帮我解决这个问题。我需要在IE11中执行我的自动化脚本。

    版本细节:

    1. 硒-2.41.0

    2. InternetExplorerDriver服务器(32位)2.40.0.0

    3. Windows 7 - 32位

4 个答案:

答案 0 :(得分:7)

这有点棘手和烦人,但可能。

您已经提到了所需的IE设置。它还缓存运行/使用之间的内容,您必须清除缓存和个人设置。我发现以下内容有助于确保启动时实例是干净的。这些是在实例化WebDriver时将传递到IE实例的选项。

本地:

    var options = new InternetExplorerOptions();
    options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
    //Clean the session before launching the browser
    options.EnsureCleanSession = true;

远程:

    capabilities = DesiredCapabilities.InternetExplorer();
    capabilities.SetCapability("ie.ensureCleanSession", true);

也许这和您提到的IE安全设置可能对您有用。

答案 1 :(得分:4)

答案 2 :(得分:0)

2017年更新:

  case "remote5555iexplorer" => {
    println(" load web-driver: remote5555iexplorer")

    val dc = DesiredCapabilities.internetExplorer()
    dc.setJavascriptEnabled(true)
     dc.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true)
    dc.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true)
    dc.setCapability(InternetExplorerDriver.ENABLE_ELEMENT_CACHE_CLEANUP, true)

    dc.setCapability(InternetExplorerDriver.NATIVE_EVENTS, false);

    remote = new RemoteWebDriver(new URL("http://localhost:5555/"), dc) 
    //remote = new InternetExplorerDriver(dc)

  }

iexplorer:11.0.9.9600.17843 更新版本:11.0.20

libraryDependencies + =“org.seleniumhq.selenium”%“selenium-ie-driver”%“3.3.1”

webdriver:IEDriverServer.exe 3.2.0.0(64位)

用于运行webdriver的

命令:IEDriverServer.exe / LOG-LEVEL = DEBUG

答案 3 :(得分:0)

有关所需功能的所有内容..在此行中将您所需的IE驱动程序功能用于IE驱动程序,并且不再重复了……它对我有用。.

            ieCapabilities.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL,false);