Selenium IE浏览器中无法获取元素

Selenium IE浏览器中无法获取元素,selenium,testing,selenium-webdriver,automation,testng,Selenium,Testing,Selenium Webdriver,Automation,Testng,IE浏览器中无法获取元素。我正在使用IE11浏览器。当我运行我的代码时,我的控制台中显示的错误为已启动InternetExplorerDriver服务器(32位)2.47.0.0 Listening on port 20577 Error show := org.openqa.selenium.NoSuchElementException: Unable to find element with id == Id_user_name_id (WARNING: The server did no

IE浏览器中无法获取元素。我正在使用IE11浏览器。当我运行我的代码时,我的控制台中显示的错误为
已启动InternetExplorerDriver服务器(32位)2.47.0.0

Listening on port 20577

Error show := org.openqa.selenium.NoSuchElementException: Unable to find element with id == Id_user_name_id (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 10.17 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 02:56:46'
System info: host: 'VDJSDEV2-PC', ip: '172.16.1.220', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, pageLoadStrategy=normal, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:20577/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
Session ID: 8bd16d35-c13d-46f7-b6cf-f9a7ddd54dda
*** Element info: {Using=id, value=Id_user_name_id}
我正在使用这些Jar文件

selenium-server-standalone-2.47.1.jar
selenium-ie-driver-2.47.0.jar
selenium-java-2.47.1-srcs.jar
selenium-java-2.47.1.jar
IEDriverServer_Win32_2.47.0

一些可能有用的建议

  • 检查元素id在页面中是否唯一且实际存在;您可以发布html页面吗(如果可能,只发布元素及其父元素)

  • 将浏览器功能超时增加到现有超时的两倍 在按id搜索元素之前

    driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS)

  • 尝试使用不同的驱动程序(Firefox或Chrome),看看问题是否仍然存在

  • 尝试通过选择器搜索元素;如果你发布html页面,我可以帮助你发送一些建议

干杯 阿兰美雄
伦敦

我发现了同样的问题,我的解决方案是: 修改IE设置以显示安全和非安全内容

  • 将每个区域的保护模式设置设置为相同的值,该值可以打开或关闭,只要每个区域的设置相同(我选中了“启用保护模式”全部)

  • 设置保护模式的方法:从“工具”菜单中选择“Internet选项…”->单击“安全”选项卡。对于每个区域(Internet/Local Internet/Trusted Web Sites/Restricted Sites),选中标签为“启用保护模式”的选项卡底部的复选框

  • 重新启动IE浏览器


  • 它对我有用,希望它也能帮助你。

    欢迎-随时发布你的代码!请看和s-祝你好运!你能分享一下你的HTML代码吗?这样可以帮助我们帮助我