1.当使用Selenium IDE 完成了脚本的录制和回放通过后,想要将脚本转换为其他语言如java、Python等,首次使用时打开Options-》Format发现没有可以转换的语言,如下:

这个时候需要设置一下,打开Options-》Options,勾选如下选项允许扩展功能,如下:

保存后重新打开Options-》Format,就可以将脚本转换成你想要的语言来显示,如下:

点击转换后,就可以将脚本装换成你想要的语言来表示,如转换成Python语言的脚本:

Selenium Webdriver

1.使用chrome浏览器运行脚本的配置

首先需要下载chromedriver,下载可以到如下地址自由选择下载版本,我选择最新的V2.9版本(我的是放在和Python安装路径目录下):

http://chromedriver.storage.googleapis.com/index.html

下载完成后,将chromedriver解压缩,将当前存放ChromeDriver.exe的路径加到系统变量path路径下:

完成后就可以在脚本中通过调用ChromeDriver来运行Chrome浏览器执行脚本:

2.当出现如下错误时:ElementNotVisibleException: Message: element not visible,表示元素初始是不可见,首先确保你的定位没有问题后,有可能是因为页面加载没有完成导致无法定位到该元素,可以通过添加:

time.sleep(5)  #延时5秒

解决问题,延时时间自己根据实际情况确认,一般在页面跳转或打开不同页面是需要添加。

3.当出现如下错误:Element is not clickable at point

主要原因是这个按钮不是可点击的按钮,可以根据错误提示进行替换备用按钮;或者由于该按钮被其他东西阻挡(弹框、浏览器没有最大化)导致无法点击,可以根据时间情况修改。

ps:我就是没有把浏览器最大化导致点击失败的!囧

4.selenium出现click单击无效无效的情况如何处理?

一般出现click单击无效的情况,主要是由于失去了跳转点击时出现失去焦点的问题(具体原因未知),可以参考解决方法:

(a)点击前先按下tab键(其他按键也可以考虑)再进行点击可以解决:

driver.find_element_by_xpath(".//*[@id='dologin']").send_keys(Keys.TAB)
driver.find_element_by_xpath(".//*[@id='dologin']").click()

(b)也可以考虑点击2次可以解决:

driver.find_element_by_xpath(".//*[@id='dologin']").click()

driver.find_element_by_xpath(".//*[@id='dologin']").click()

5.当出现如下错误selenium.common.exceptions.StaleElementReferenceException:
Message: stale element reference: element is not attached to the page
document,意思是页面元素没有连接成功,一般是由于返回或刷新页面导致丢失,解决版本可以参考:

(a)重新刷新加载页面

(b)重新获取页面元素

6.Selenium webdriver启动chrome浏览器出现提示:--ignore certificate errors

解决办法如下(在启动driver时添加一个选项,将提示去除即可):
option=webdriver.ChromeOptions()
option.add_argument("test-type")
driver = webdriver.Chrome(chrome_options=option)
 
 
 

爬虫-Selenium -抱错ElementNotVisibleException: Message: element not visible的更多相关文章

  1. selenium.common.exceptions.ElementNotVisibleException: Message: element not visible处理方法:selenium针对下拉菜单事件的处理

    使用Selenium爬虫时,可能会遇到一些下拉菜单,动态加载,如果直接使用find_element_by_函数会报错,显示selenium.common.exceptions.ElementNotVi ...

  2. ElementNotVisibleException: Message: element not visible

    selenium自动化测试中,经常会报异常: 可能会有各种疑问,元素可以定位到啊.为什么报以下异常? ElementNotVisibleException: Message: element not ...

  3. python + web自动化,点击不生效,提示“selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable at point (117, 674)”

    前言: 在做web自动化时,遇到一个缩放了浏览器比例的操作,从100%缩小到80%,再进行点击的时候,弹出报错信息,无法点击 selenium.common.exceptions.ElementCli ...

  4. selenium之 坑(StaleElementReferenceException: Message: Element not found in the cache...)

    今天给大家分享一个selenium中经常会有人遇到的坑: selenium.common.exceptions.StaleElementReferenceException: Message: Ele ...

  5. python+selenium:点击页面元素时报错:WebDriverException: Message: Element is not clickable at point (1372.5, 9.5). Other element would receive the click: <li style="display: list-item;" id="tuanbox"></li>

      遇到一个非常郁闷的问题,终于解决了, 问题是这样的,NN网站的价格计划,每一个价格计划需要三连击才能全部点开,第一个房型的价格计划是可以正确三连击打开的,可是第二个房弄就不行了,报错说不是可点击的 ...

  6. python控制selenium点击登录按钮时报错 unknown error: Element is not clickable at point

    利用python控制selenium进行一个网页的登录时报错: C:\Users\Desktop\selenium\chrome>python chrome.py selenium.common ...

  7. python selenium 报错unknown error: cannot focus element 解决办法

    登录框由于js限制,定位到元素后无法sendkey ,sendky报错如下: selenium.common.exceptions.WebDriverException: Message: unkno ...

  8. selenium之坑:点击后页面刷新重新获取刷新前的页面(StaleElementReferenceException:Message:Element not found in the cache...)

    循环点击一列链接,但只能点到第一个,第二个失败,这是为什么,因为第二个已经是新页面,当然找不到之前页面的元素,虽然元素没变,甚至是后退回来,页面都没有变,为什么是新页面,页面长的一样不代表是同一张页面 ...

  9. selenium之坑(StaleElementReferenceException: Message: Element not found in the cache...)

    有时候循环点击一列链接,只能点到第一个,第二个就失败了 原因是第二个已经是新页面,当然找不到之前页面的元素.就算是后退回来的,页面也是不一样的 页面长的一样不一定是同一张页面,就像两个人长的一样不一定 ...

随机推荐

  1. Mac git 的使用

    1. mac 安装git brew install git 2.初使化 git config --global user.name "mygit" git config --glo ...

  2. java 相关软件使用趋势

     http://www.baeldung.com/java-in-2017  https://mp.weixin.qq.com/s?__biz=MzI4NjYwMjcxOQ==&mid=224 ...

  3. mysql二进制安装,升级,多实例部署

    目标 理解线上部署考虑的因素 学会编译安装以及二进制安装mysql 学会升级mysql 学会多实例部署mysql数据库 学会合理部署mysql线上库   考虑因素: 版本选择,5.1,5.5还是5.6 ...

  4. APNS push server端 SSL3.0 转 TLS (iPhone苹果推送服务)

    (转载此文,请说明原文出处) 苹果的官方公布 Update to the Apple Push Notification Service October 22, 2014 The Apple Push ...

  5. Elite Container DELPHI下的一个轻量级IoC对象容器

    一.简介: Elite Container是DELPHI下的一个轻量级IoC对象容器(IoC:Inverse of Control,反转控制).它是参考了Java中的Spring框架(主要是配置文件的 ...

  6. script脚本中写不写$(document).ready(function() {});的差别

    $(document).ready() 里的代码是在页面内容都载入完才运行的,假设把代码直接写到script标签里.当页面载入完这个script标签就会运行里边的代码了,此时假设你标签里运行的代码调用 ...

  7. 每天一个 Linux 命令(57):ss命令

    ss是Socket Statistics的缩写.顾名思义,ss命令可以用来获取socket统计信息,它可以显示和netstat类似的内容.但ss的优势在于它能够显示更多更详细的有关TCP和连接状态的信 ...

  8. vue2.0 watch 详解

    vue官网解释: 一个对象,键是需要观察的表达式,值是对应回调函数.值也可以是方法名,或者包含选项的对象.Vue 实例将会在实例化时调用 $watch(),遍历 watch 对象的每一个属性. 也就是 ...

  9. NodeJS待重头收拾旧山河(重拾)

    介绍 Node.js®是一个基于Chrome V8 JavaScript引擎构建的JavaScript运行时. Node.js使用事件驱动的非阻塞I / O模型,使其轻便且高效. Node.js的包生 ...

  10. HDU 2255 奔小康赚大钱 KM裸题

    #include <stdio.h> #include <string.h> #define M 310 #define inf 0x3f3f3f3f int n,nx,ny; ...