当编写自动化脚本,定位浏览器元素时,报如下错误:

代码:

>>> # coding=utf-8
>>> from selenium import webdriver
>>> driver = webdriver.Ie()
>>> driver.get("www.baidu.com")
>>> driver.find_element_by_id("kw").send_keys("Selenium2")

报错:

解决方法:

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. (32bit Windows看这里。)

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.(64bit Windows看这里。)

翻译过来的意思即,修改你的注册表(Run->regedit->Enter),路径如下:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE

如果FeatureControl下没有FEATURE_BFCACHE,就以FEATURE_BFCACHE为名new一个key!并在其下创建一个DWORD,取名为:iexplore.exe,value为0。

修改完你的注册表后,重启你的计算机。

【参照】:http://blog.csdn.net/angel_xiaa/article/details/52212340

但是发现我再定位元素时候还是报错,我就怀疑是不是Selenium版本问题,因为我安装的是Selenium3.X的版本,然后我运行cmd把3.X卸载重新安装2.X版本就好了。

卸载命令:pip uninstall selenium //卸载当前安装的包

安装命令:pip install selenium==2.48.0 //指定版本号安装

查看命令:pip show selenium //查看当前包的版本信息

=============注意:如果使用的IE浏览器还是报错,请参考下面网址解决=================

地址:http://www.cnblogs.com/testervic/articles/6705159.html

【Python】selenium调用IE11浏览器,报错“找不到元素”NoSuchWindowException: Message:Unable to find element on closed window的更多相关文章

  1. python selenium+phantomjs alert()弹窗报错

    问题:用selenium+phantomjs 模拟登陆,网页用JavaScript的alert("登陆成功")弹出框,但是用switch_to_alert().accept()报错 ...

  2. java selenium启动火狐浏览器报错:Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:14.666Z

    Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA Build in ...

  3. 解决selenium 启动ie浏览器报错:Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones

    启动ie代码: System.setProperty("webdriver.ie.driver", "bin/IEDriverServer.exe"); Web ...

  4. selenium启动IE浏览器报错:Unexpected error launching Internet Explorer. Browser zoom level was set to

    解决此问题的方法就是查看自己的浏览器是否没有放大至100%,如下 如果不是100%就会报错

  5. selenium启动IE浏览器报错:selenium.common.exceptions.WebDriverException: Message: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode mu

    意思是浏览器的保护模式设置不一致所导致 解决方案-->修改IE设置 将所有区域的保护模式勾选去掉即可

  6. 安装火狐浏览器报错找不到VCRUNTIME140_1.DLL

    产生原因参考及下载地址:https://cn.dll-files.com/vcruntime140_1.dll.html vcruntime140_1.dll 相关的错误可能源于多种不同原因.比如,错 ...

  7. python脚本中selenium启动浏览器报错os.path.basename(self.path), self.start_error_message) selenium.common.excep

    在python脚本中,使用selenium启动浏览器报错,原因是未安装浏览器驱动,报错内容如下: # -*- coding:utf-8 -*-from selenium import webdrive ...

  8. python+selenium自动化测试,浏览器最大化报错解决方法

    此处以谷歌浏览器为例 [问题1]缺少chrome驱动,webdriver调用谷歌浏览器的时候就报错了,如下图: [原因分析]缺少谷歌驱动程序 [解决办法] 1.查看本地安装chrome浏览器版本 2. ...

  9. Windows 7上打开IE浏览器报错:无法启动此程序,因为计算机中丢失api-ms-win-core-path-|1-1-0.dll。尝试重新安装该程序以解决此问题。

    Windows 7上打开IE浏览器报错: 1. 重新安装IE11也没有解决该问题 2. 在其他Win7电脑也搜索不到该文件,但是能使用IE浏览器. 3. 从网上找了一个dll文件,注册时提示如下图

随机推荐

  1. 【简单的原创】div简单轮换显示

    原文发布时间为:2009-05-10 -- 来源于本人的百度文章 [由搬家工具导入] <html><head><title>div简单轮换显示</title& ...

  2. Codeforces 935D Fafa and Ancient Alphabet

    题目链接 题意 给定两个\(n\)位的\(m\)进制数\(s1,s2\),所有出现的\(0\)均可等概率地被其他数字替换,求\(s1\gt s2\)的概率. 思路 从高位到低位,根据每一位上相应的\( ...

  3. AutoResetEvent 和 ManualResetEvent 多线程应用

    AutoResetEvent 1.用于在多线程,对线程进行阻塞放行 static AutoResetEvent auth0 = new AutoResetEvent(false); static Au ...

  4. 牛客网 牛客小白月赛1 F.三视图

    F.三视图   链接:https://www.nowcoder.com/acm/contest/85/F来源:牛客网     这个题自己想一下三维的,正视图和左视图中y轴为行数,x轴和z轴是列数,因为 ...

  5. 机器学习(4):数据分析的工具-pandas的使用

    前面几节说一些沉闷的概念,你若看了估计已经心生厌倦,我也是.所以,找到了一个理由来说一个有兴趣的话题,就是数据分析.是什么理由呢?就是,机器学习的处理过程中,数据分析是经常出现的操作.就算机器对大量样 ...

  6. Spring Cloud学习总结(非原创)

    文章大纲 一.课程内容总结二.课程学习地址三.学习资料下载四.参考文章 一.课程内容总结   二.课程学习地址 第一天:https://www.jianshu.com/p/a086421f4bfd第二 ...

  7. gtest 自动化测试 部署

    1.部署 a)编译框架 1.1下载gtest库1.6.0 并解压到文件夹 "/user/{user}/gtest.1.6.0" 下载地址:https://code.google.c ...

  8. 从C的声明符到Objective-C的Blocks语法

    原文链接:http://nilsou.com/blog/2013/08/21/objective-c-blocks-syntax/ 在这个post中,我先以C简单和内置复杂的声明开始,直到我们开始接触 ...

  9. 传输层:UDP 协议

    一.传输层协议 从之前介绍的网络层协议来看,通信的两端是两台主机,IP 数据报首部就标明了这两台主机的 IP 地址.但是从传输层来看,是发送方主机中的一个进程与接收方主机中的一个进程在交换数据,因此, ...

  10. python+tesseract验证码识别的一点小心得

    由于公司需要,最近开始学习验证码的识别 我选用的是tesseract-ocr进行识别,据说以前是惠普公司开发的排名前三的,现在开源了.到目前为止已经出到3.0.2了 当然了,前期我们还是需要对验证码进 ...