![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
selenium
shixiu_yuan
想要飞得更高,就要把地平线忘掉。
展开
-
selenium对弹窗(alert)的处理
1、弹窗selenium提供 switch_to_alert方法:捕获弹出对话框(可以定位alert、confirm、prompt对话框)switch_to_alert() --定位弹出对话框text() --获取对话框文本值accept() --相当于点击“确认”dismiss() --相当于点击“取消”send_keys() --输入值(alert和confirm没有输入对话框,所以就不用能用了转载 2021-11-04 11:09:58 · 2829 阅读 · 0 评论 -
xpath中ends-with无法定位问题的解决办法
在使用xpath的模糊匹配以什么结尾时,遇到如下问题: //input[ends-with(@id,‘w’)] 定位不到input标签中的id以w结尾的元素,报错如下SyntaxError: Failed to execute ‘evaluate’ on ‘Document’: The string ‘//input[ends-with(@id,‘w’)]’ is not a valid XPath expression.(Session info: chrome=94.0.4606.81)查询原创 2021-10-25 11:18:37 · 2592 阅读 · 0 评论 -
Selenium-xpath定位
序言:前面介绍了利用浏览器的debug工具获取xpath地址,但是这个工具不是万能的,有时候直接复制粘贴会定位不到。这个时候就需要自己手动去写xpath路径了。接下来将详细讲解xpath的常用语法。一、xpath的基本概念和基本语法可上菜鸟教程和w3cschool查看相关资料:http://www.runoob.com/xpath/xpath-tutorial.html、http://www.w3school.com.cn/xpath/index.asp谓语(Predicates)谓语用来查找某个原创 2021-10-25 11:13:15 · 210 阅读 · 0 评论 -
Selenium中遇到 StaleElementReferenceException 异常
现在开始,不定期更新所学所知。以便更好的检阅自己的成长。在自动化测试过程中,代码并没有任何错误,可运行过程中多次遇到遇到如下报错:selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable目前我只用第三种解决方法如下:方法一:使用time.sleep()可降低发生此异常的概率,但是并非百分百有效,并且浪费时间。方法二:使用driver.fresh()刷新页面后再重新定原创 2021-04-16 15:06:38 · 604 阅读 · 0 评论 -
USB: usb_device_handle_win.cc:1056 Failed to read descriptor from node connection
最近在帮新同事搭建python+selenium+pytest自动化测试环境,发现遇到如下报错:[6452:9780:0415/100836.539:ERROR:device_event_log_impl.cc(214)] [10:08:36.526] USB: usb_device_handle_win.cc:1056 Failed to read descriptor from node connection: A device attached to the system is not functi原创 2021-04-15 10:59:29 · 9916 阅读 · 1 评论 -
selenium--浏览器的基本操作方法
打开百度浏览器设置等待时间页面刷新前进和后退浏览器窗口大小设置截屏退出注:具体实现请看如下代码coding:utf-8from selenium import webdriverfrom time import sleepdriver = webdriver.Firefox()driver = webdriver.Ie() #打开IE浏览器dr...原创 2019-12-04 21:05:42 · 358 阅读 · 0 评论 -
Selenium3 + python自动化-环境搭建
Selenium3在Selenium2的基础上做了一些调整,最明显的区别是selenium2只支持Firefox版本46以下版本;而selenium3可以支持47以上版本,但需要安装geckodriver.exe驱动,并添加到环境变量path下,本人的环境:win10+python3.6+selenium3+Firefox47以上版本...原创 2019-12-03 14:11:58 · 167 阅读 · 0 评论 -
Selenium发展史
Jason Huggins在2004年发起了Selenium项目,当时身处ThoughtWorks的他,为了不想让自己的时间浪费在无聊的重复性工作中,幸运的是,所有被测试的浏览器都支持Javascript。Jason和他所在的团队采用Javascript编写一种测试工具来验证浏览器页面的行为;这个JavaScript类库就是Selenium core,同时也是sel...转载 2019-10-26 12:20:12 · 204 阅读 · 0 评论