main.py 1.1 KB

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