Skip to main content
 首页 » 编程设计

Python 3.5 Selenium 网络驱动程序 IE

2024年10月17日8youxin

我遇到了 IE webdriver 的问题,如果我打开一个页面,我可以找到该页面中的所有内容,但是如果我从一个页面移动到另一个具有不同 URL 的页面,当我尝试搜索某个元素时,我每次都会收到相同的错误留言:

selenium.common.exceptions.NoSuchWindowException: Message: Unable to get browser

我的代码很简单:

from selenium import webdriver  
import time 
 
driver = webdriver.Ie() 
driver.get('http://www.google.com/xhtml') 
driver.get("http://www.virgilio.it/")#example 
time.sleep(2) 
print(driver.current_url) 

主要问题是仅在 IE webdriver 上失败,但它在 Firefox 和 Chrome webdriver 上工作。

请帮忙!?!?!?!

请您参考如下方法:

InternetExplorerDriver wiki在 SeleniumHQ 与这里相关:

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.