2017-08-31 39 views
0
from selenium import webdriver 
import csv 
import time 

url_results=[] 
driver_ie = webdriver.Ie('C:\\Users\\aviv\\Desktop\\IEDriverServer') 

with open ('C:\\Users\\aviv\\Desktop\\urlspart.txt','r') as d: 
    urls= d.read().splitlines() 

    for i,url in enumerate(urls): 

     try: 
      print "URL: " + url 
      driver_ie.get(url) 
      time.sleep(7) 
      current_url_ie = driver_ie.current_url 
      redirect_ie='No' 
      if current_url_ie == 'https://www.aviv.com': 
       redirect_ie ='Yes' 

     except Exception,e: 
      redirect_ie = 'error' 
      print e, Exception 



     writer.writerow([i,url,redirect_ie]) 
ofile.close() 

此代码抛出异常并显示消息:“Unable to get browser”。python中的硒webdriver - 无法获取浏览器

我已经更改了Internet选项 - >安全并签署了“启用保护模式”, 但是错误仍然存​​在。

任何解决方案?

+0

你为什么要初始化'driver_ie'两次? –

+0

我编辑它,这不是问题。 –

+0

您可以粘贴完整的错误堆栈跟踪以进一步分析吗? – DebanjanB

回答

0

仅适用于IE 11,您需要在目标计算机上设置注册表项,以便驱动程序可以维护与创建的Internet Explorer实例的连接。

对于32位Windows安装,您必须在注册表编辑器中考查的重点是

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子键可能存在也可能不存在,如果不存在则应该创建。重要说明:在此密钥内部,创建一个名为iexplore.exe的DWORD值,值为0

http://heliumhq.com/docs/internet_explorer下载注册表文件。

请参阅https://code.google.com/p/selenium/wiki/InternetExplorerDriver了解更多必需的IE配置步骤。

另请参考:

https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/6511

希望它会帮助你:)

+0

谢谢,但我也试过了,错误依然存在。 –

0

可能是因为在驱动程序路径的终点缺少.exe文件。请按以下所示添加.exe。它可能适合你。

driver_ie = webdriver.Ie('C:\\Users\\aviv\\Desktop\\IEDriverServer.exe') 
相关问题