Python3+Selenium+unittest自动化UI测试框架

 
python测试框架

关于框架:

Vantpy框架基于Selenium2+ unittest 搭建的WebUI自动化测试框架

特点:

使用POM(页面对象模式)设计,使我们写的代码更加简单,后期更加容易维护以及复用性更高

支持多种定位方式,包括(xpath/css/ID/text/link_text/name)

框架集成了Selenium的常用定位方法,也是在我们经常使用到的方法

使用HTMLTestRunner框架自动生成测试报告,使我们更直观查看报告的内容

集成断言一层验证,截图二层验证的方法,使我们的定位问题精准性更高

部署环境:

Python 3.6+:https://www.python.org/

Selenium3.8.0+:https://pypi.python.org/pypi/selenium

支持的浏览器及驱动:

基于Selenium支持的所有浏览器

browser=="Chrome"

browser=="firefox"

browser=="IE"

browser=="phantomjs"

browser=="opera"

browser=="edge"

geckodriver(Firefox):https://github.com/mozilla/geckodriver/releases

Chromedriver(Chrome):https://sites.google.com/a/chromium.org/chromedriver/home

IEDriverServer(IE):http://selenium-release.storage.googleapis.com/index.html

operadriver(Opera):https://github.com/operasoftware/operachromiumdriver/releases

MicrosoftWebDriver(Edge):https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver

定位元素方式:

search_loc = (By.XPATH,'//*[@id="kw"]')

def input_baidu_text(self,text):

    self.find_element(*self.search_loc).send_keys(text)

By.NAME,'百度'

By.ID,'ID'

By.LINK_TEXT,'Link_text'

By.CSS_SELECTOR,'CSS'

By.CLASS_NAME,'Class_name'

...

自动化测试报告:

 
测试报告

框架的源码已经分享到github了,喜欢学习的话可以直接clone就可以了:点击这里



作者:G2Bent
链接:https://www.jianshu.com/p/4278386e924b
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

猜你喜欢

转载自www.cnblogs.com/x666-6/p/9070314.html