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

关于框架:

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

特点:

  • 使用POM(页面对象模式)设计,使我们写的代码更加简单,后期更加容易维护以及复用性更高
  • 支持多种定位方式,包括(xpath/css/ID/text/link_text/name)
  • 框架集成了Selenium的常用定位方法,也是在我们经常使用到的方法
  • 使用HTMLTestRunner框架自动生成测试报告,使我们更直观查看报告的内容
  • 集成断言一层验证,截图二层验证的方法,使我们的定位问题精准性更高

部署环境:

支持的浏览器及驱动:

基于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'   
...

自动化测试报告

enter image description here

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

posted on 2018-01-29 10:01  G2Bent  阅读(1639)  评论(0编辑  收藏  举报

导航