使用Selenium爬虫时,可能会遇到一些下拉菜单,动态加载,如果直接使用find_element_by_函数会报错,显示selenium.common.exceptions.ElementNotVisibleException: Message: element not visible. 意思是element是不可见的.所以无法获取到.这时候就遇到一个难题,怎么把element变成可见的呢? 这时候,我们就用ActionChains来模拟效果 ActionChains(driver).clic…
前言: 在做web自动化时,遇到一个缩放了浏览器比例的操作,从100%缩小到80%,再进行点击的时候,弹出报错信息,无法点击 selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable at point (117, 674) (Session info: chrome=76.0.3809.132) debug一下代…
1.当使用Selenium IDE 完成了脚本的录制和回放通过后,想要将脚本转换为其他语言如java.Python等,首次使用时打开Options->Format发现没有可以转换的语言,如下: 这个时候需要设置一下,打开Options->Options,勾选如下选项允许扩展功能,如下: 保存后重新打开Options->Format,就可以将脚本转换成你想要的语言来显示,如下: 点击转换后,就可以将脚本装换成你想要的语言来表示,如转换成Python语言的脚本: Selenium Webdr…
抓取网页代码后,由于是在同一个li标签下,所以使用一次性抓取,所有的a标签,然后循环做不同的操作,但是抛出找不到元素异常. def office_page(_chrome: Chrome): sn = '官网首页' _xpath = '//li[@class="scNav_Item"]/a' sc_nav_list = _chrome.driver.find_elements_by_xpath('//li[@class="scNav_Item"]/a') print…
selenium自动化测试中,经常会报异常: 可能会有各种疑问,元素可以定位到啊.为什么报以下异常? ElementNotVisibleException: Message: element not visible 原因: 元素在前台代码document中可以找到,但是不代表该元素就显示在了页面上. 所以报上述异常的原因就是,元素未显示在界面上. 能过我们测试中会自定义一下,找元素的功能: def find_element(self,*loc): """ 在指定时间内,查找元…
1.查看安装的chrome浏览器版本 2.查看版本对应的驱动 https://sites.google.com/a/chromium.org/chromedriver/downloads 下载后拷贝到/usr/local/bin/目录下 结果在运行程序的时候右报错:selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH 后来网上查下修改如下代码: c…
一.说明 在使用python3+selenium写自动升级程序的时侯,碰到一个弹出对话框需要点击确认的场景.弹出的对话框如下图所示. 对于弹框各种资料都说通过switch_to.alert属性获取对话框对象,然后使用该对象的accept()方法点击确认. 但使用该方法,一直报错:“selenium.common.exceptions.NoAlertPresentException: Message: No alert is active”,截图如下: 二.对话框处理 2.1 基本消息框处理 Ja…
在使用selenium+phantomjs的时候在Windows平台下能够正常工作,在Linux下却不能,并得到错误信息: selenium.common.exceptions.TimeoutException: Message: Screenshot: available via screen 在ST上找到答案:http://stackoverflow.com/a/36159299/4447404 driver = webdriver.PhantomJS(service_args=['--ig…
1.安装pip3 install selenium 2.使用browser=webdriver.Chrome()时报错 :selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home 解决方法如下: 1.查看自己chr…
有一年多没写web自动化了,今天搭建环境的时候报了一个常见错误,但是处理过程有点闹心,报错就是常见的找不到驱动<selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH>,下载对应版本的驱动,放至chrome的安装目录的application下面,但是还一直报相同的错误(印象中一年之前遇到相同的问题不是这么处理的,但是记不起来),查了一些blog,找…