简体   繁体   中英

Python 3.5 Selenium Webdriver IE

I got a problem with IE webdriver, if I open a page I can find everything in that page but if I move from a page to another with different URL, when I try to search some element I receive every time the same error message:

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

My code is very simple:

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)

The main problem is that fail just with IE webdriver but it's working with the Firefox and Chrome webdriver.

Some help Please!?!?!?!

The InternetExplorerDriver wiki at SeleniumHQ is relevant here:

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 .

To created commands from @Steven's answer. Just run these as Administrator:

REG Add "HKLM\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE" /v "iexplore.exe" /t REG_DWORD 0
REG Add "HKLM\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE" /v "iexplore.exe" /t REG_DWORD 0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM