debug(0)
发布于2019-12-07 22:54 阅读(2304) 评论(0) 点赞(25) 收藏(0)
ATF(Auto_Test_Framework)Vantpy1.03
关于框架:
重要声明:Vantpy1.0原作者Vant 944921374@qq.com Vantpy框架基于Selenium+Yaml+Unittest搭建的WebUI自动化测试框架
持续更新By jasonleeyag@163.com
特点:
部署环境:
更新日志:
1.01 封装了选择窗口、选择iframe、点击alert方法。
1.02 将单进程report样式从引用百度修改为离线样式。
1.03 增加多进程及并发运行模式。
使用到的package:
pip install selenium
pip install BeautifulReport
pip install pyyaml
pip install tomorrow3
pip install requests
第三方插件
Autoit V3 HTMLTestRunner3
支持的浏览器及驱动:
基于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
定位元素方式:
- class BaiduPage(BasePage):
- """
- 在这里写定位器,通过元素属性定位元素对象
- """
- search_loc =(By.XPATH,'//*[@id="kw"]')#定位百度文本框
-
- def input_baidu_text(self,text):
- self.send_key(self.search_loc,text)
读取yaml数据
- brwserType:
- browserName : Chrome
-
- testUrl:
- URL : https://www.baidu.com
- file_path = os.path.dirname(os.getcwd())
- name_path = file_path + '\conf\config.yaml'
- with open(name_path, 'r') as f:
- temp = yaml.load(f.read())
日志输出
- 2018-06-02 14:58:13,521 - INFO - You had select Chrome browser.
- 2018-06-02 14:58:13,524 - INFO - The test url is: https://www.baidu.com
- 2018-06-02 14:58:19,629 - INFO - Starting Chrome browser.
- 2018-06-02 14:58:20,456 - INFO - Open url: https://www.baidu.com
- 2018-06-02 14:58:21,607 - INFO - Maximize the current window.
- 2018-06-02 14:58:21,609 - INFO - Set implicitly wait 5 seconds.
- 2018-06-02 14:58:21,609 - INFO - Clear input-box: //*[@id="kw"]...
- 2018-06-02 14:58:22,723 - INFO - Input element by xpath: //*[@id="kw"]...
- 2018-06-02 14:58:22,723 - INFO - Input: selenium
生成测试报告
- def report():
- if len(sys.argv) > 1:
- report_name = os.path.dirname(os.getcwd()) + '\\report\\' + sys.argv[1] + '_result.html'
- else:
- now = time.strftime("%Y-%m-%d_%H_%M_%S_")
- # 需要查看每段时间的测试报告,可以这样写:
- # report_name = os.getcwd() + '\\report\\'+now+'result.html'
- report_name = os.path.dirname(os.getcwd()) + '\\report\\result.html'
- return report_name
-
- fp = open(report(), 'wb')
- Runner = HTMLTestRunner(
- stream=fp,
- title='测试报告',
- description='测试用例执行情况'
- )
测试报告(单进程模式)
其他注意事项
运行报错找不到某某文件路径,请自行修改BrowserDriver.py以及logger.py
作者:慧雅
链接:https://www.pythonheidong.com/blog/article/170259/fbbaa32bb0cba7642f24/
来源:python黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 python黑洞网 All Rights Reserved 版权所有,并保留所有权利。 京ICP备18063182号-1
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!