1234567891011121314151617181920212223242526272829 |
- import logging
- from ctrip import ctrip
- import sys
- # 该测试用例只是简单的简单的说明自动化测试如果编写,该脚本模拟用户在携程首页上点击机票和火车票两个按钮.
- # 该用例环境
- # python3.x Chrome浏览器
- # 如有疑问,请及时联系
- if "__main__" == __name__:
- print("auto test start ...")
- # 初始化日志配置
- LOG_FORMAT = "%(filename)s [%(levelname)s]: %(message)s"
- DATE_FORMAT = "%Y/%m/%d %H:%M:%S"
- logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(filename)s line:%(lineno)d [%(levelname)s] %(message)s',
- datefmt='%Y/%m/%d %H:%M:%S',)
- logging.root.level = logging.INFO
- # 初始化好日志等其他依赖的配置之后,启动测试,如果成功则释放所有占用资源,即调用close(),若失败则停留在错误页面
- ctrip_tester = ctrip.Ctrip()
- err = ctrip_tester.run()
- if err is not None:
- logging.debug("auto test some error happend %s", err.to_string())
- sys.exit(1)
- ctrip_tester.close()
- logging.debug("auto test success")
- print("auto test stop")
|