Unable to get browser (Selenium::WebDriver::Error::NoSuchWindowError)

运行Ruby程序调用Internet Explorer 11会出现这样的错误,不是因为IEDriverServer 出现问题,而是因为Internet Explorer 11 自身的原因。对于这样的问题有如下的解决方案:
1.设置–>Internet选项–>安全
这里写图片描述
这里将图片中标注为2的四个选项(Internet,本地Internet,受信任的站点,受限制的站点)中每一个标注为3的复选框(启用保护模式……)选中,如图所示。这个需要重新启动计算机才能生效。
2. 维基百科中的方法
对于IE 11,您将需要在目标计算机上设置注册表项,以便驱动程序可以维护与其创建的Internet Explorer实例的连接。
对于32位Windows,必须在注册表编辑器(win+r并运行regedit)中检查的密钥是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子项可能或可能不存在,如果不存在,则应该创建,在此键内,创建一个值为0的名为iexplore.exeDWORD值。
(谷歌翻译,凑合着看吧)
维基百科原文请点击这里

Traceback (most recent call last): File "C:\Users\jzhcc\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\common\driver_finder.py", line 42, in get_path path = SeleniumManager().driver_location(options) if path is None else path File "C:\Users\jzhcc\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\common\selenium_manager.py", line 96, in driver_location result = self.run(args) File "C:\Users\jzhcc\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\common\selenium_manager.py", line 121, in run raise WebDriverException(f"Unsuccessful command executed: {command}.\n{result}{stderr}") selenium.common.exceptions.WebDriverException: Message: Unsuccessful command executed: C:\Users\jzhcc\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\common\windows\selenium-manager.exe --browser chrome --output json. error sending request for url (https://chromedriver.storage.googleapis.com/LATEST_RELEASE_49): error trying to connect: dns error: 这是在主机名解析时通常出现的暂时错误,它意味着本地服务器没有从权威服务器上收到响应。 (os error 11002) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\jzhcc\Desktop\222.py", line 3, in <module> browser = webdriver.Chrome() File "C:\Users\jzhcc\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 47, in __init__ self.service.path = DriverFinder.get_path(self.service, self.options) File "C:\Users\jzhcc\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\common\driver_finder.py", line 44, in get_path raise NoSuchDriverException(f"Unable to obtain {service.path} using Selenium Manager; {err}") selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain chromedriver using Selenium Manager; Message: Unsuccessful command executed: C:\Users\jzhcc\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\common\windows\selenium-manager.exe --browser chrome --output json. error sending request for url (https://chromedriver.storage.googleapis.com/LATEST_RELEASE_49): error trying to connect: dns error: 这是在主机名解析时通常出现的暂时错误,它意味着本地服务器没有从权威服务器上收到响应。 (os error 11002) ; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location
07-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值