main.py 1.1 KB

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