本地 HTML 页面上的 IEDriverServer 以 NoSuchWindowException 结尾:无法获取浏览器
IEDriverServer on local HTML pages ends with NoSuchWindowException: Unable to get browser
我在 Win8.1 上使用 32 位 IE11。
我有一些在 IE11 上执行的 Selenium 脚本(Python 绑定)。
使用 IEDriverServer,我已经完成了 InternetExplorerDriver-wiki page 上建议的所有步骤,总的来说,IEDriver 工作正常。
但是,如果我尝试获取本地HTML页面,例如:
from selenium import webdriver
ie = webdriver.Ie()
url = "file:///D:/dev/proof_of_concept/html/liki.html"
ie.get(url)
print(ie.current_url)
我在 return 中得到这个异常:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 426, in current_url
return self.execute(Command.GET_CURRENT_URL)['value']
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 173, in execute
self.error_handler.check_response(response)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 166, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchWindowException: Message: 'Unable to get browser'
有很多关于一般 IE11 问题(使用注册表解决方案)的线索,但我无法通过 本地页面 .[= 找到针对此特定问题的任何解决方案14=]
是否存在我不知道的某种限制或与安全区域相关的内容?
谢谢!
IE 驱动程序不支持使用 file://
协议打开 HTML 文档。造成这种情况的原因有很多,但有两个特别突出。首先,对于使用 file://
协议在 IE 中打开的文档,默认情况下禁用 JavaScript。由于 IE 驱动程序需要 JavaScript 才能正常运行,因此这不是启动器。其次,使用 file://
协议打开的文档在单独的保护模式区域中打开,该区域通常不会显示在“选项”对话框中。因此,无法避免跨越保护模式边界,并且当跨越这样的边界时,驱动程序用于自动化 IE 的 COM 对象将被孤立。
启动一个简单的网络服务器来提供您感兴趣的自动化文档并不难。这才是正确的前进方向。
我在 Win8.1 上使用 32 位 IE11。 我有一些在 IE11 上执行的 Selenium 脚本(Python 绑定)。
使用 IEDriverServer,我已经完成了 InternetExplorerDriver-wiki page 上建议的所有步骤,总的来说,IEDriver 工作正常。
但是,如果我尝试获取本地HTML页面,例如:
from selenium import webdriver
ie = webdriver.Ie()
url = "file:///D:/dev/proof_of_concept/html/liki.html"
ie.get(url)
print(ie.current_url)
我在 return 中得到这个异常:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 426, in current_url
return self.execute(Command.GET_CURRENT_URL)['value']
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 173, in execute
self.error_handler.check_response(response)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 166, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchWindowException: Message: 'Unable to get browser'
有很多关于一般 IE11 问题(使用注册表解决方案)的线索,但我无法通过 本地页面 .[= 找到针对此特定问题的任何解决方案14=]
是否存在我不知道的某种限制或与安全区域相关的内容?
谢谢!
IE 驱动程序不支持使用 file://
协议打开 HTML 文档。造成这种情况的原因有很多,但有两个特别突出。首先,对于使用 file://
协议在 IE 中打开的文档,默认情况下禁用 JavaScript。由于 IE 驱动程序需要 JavaScript 才能正常运行,因此这不是启动器。其次,使用 file://
协议打开的文档在单独的保护模式区域中打开,该区域通常不会显示在“选项”对话框中。因此,无法避免跨越保护模式边界,并且当跨越这样的边界时,驱动程序用于自动化 IE 的 COM 对象将被孤立。
启动一个简单的网络服务器来提供您感兴趣的自动化文档并不难。这才是正确的前进方向。