seldom UI自动化测试框架

it2023-09-07  81

seldom UI自动化测试框架

seldom文档地址:https://github.com/SeldomQA/seldom

简介

基于 selenium 和 unittest 的 Web UI自动化测试框架。

特点

提供更加简单API编写自动化测试。提供脚手架,快速生成自动化测试项目。自动生成HTML测试报告生成。自带断言方法,断言title、URL 和 text。支持用例参数化。支持用例失败重跑。用例失败/错误截图。

下载安装

> pip install seldom

运行过程中出现的报错及解决方案

报错

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH

解决

https://blog.csdn.net/weixin_44318830/article/details/103339273###

主要的原因还是因为selenium模拟的客户端对浏览器的操作,但相应浏览器的驱动版本不匹配导致的。

打开浏览器,在地址栏输入chrome://version/便可以查看到谷歌当前的版本号接着进入谷歌浏览器驱动的下载网址http://chromedriver.storage.googleapis.com/index.html下载上一步对应的版本号下载完我们解压开,就是chromedriver.exe把它放到下面两个路径下 一个是在C盘的路径下,具体的位置C:\Program Files (x86)\Google\Chrome\Application 另一个python安装的目录下

通过xpath定位,xpath定位有N种写法,这里列几个常用写法:

dr.find_element_by_xpath("//*[@id='kw']") dr.find_element_by_xpath("//*[@name='wd']") dr.find_element_by_xpath("//input[@class='s_ipt']") dr.find_element_by_xpath("/html/body/form/span/input") dr.find_element_by_xpath("//span[@class='soutu-btn']/input") dr.find_element_by_xpath("//form[@id='form']/span/input") dr.find_element_by_xpath("//input[@id='kw' and @name='wd']")
最新回复(0)