一、logging简易封装:
代码可参考此文:https://www.cnblogs.com/fengyiru6369/p/8052953.html
二、base中初始化LOG:
(1)LOG = logger.Logger("base").getlog()
(2) def __init__ ( self, driver ):
self.log=LOG
# -*- coding:utf-8 -*- from appium.webdriver.common.touch_action import TouchAction import os,sys import logger #所有pages继承父类base封装的方法 LOG = logger.Logger("base").getlog() class base: _path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) #初始化driver def __init__ ( self, driver ): self.driver = driver self.log=LOG
三、pages继承base
(1)pages继承base
(2)pages调用base的log
(3)实现 self.log.debug("xxx")测试步骤打印log
# -*- coding:utf-8 -*- from selenium.webdriver.common.by import By from Pages.basepage import base class search(base): _serch = (By.ID, "com..mm:id/r_") def search_contacts( self, name ) : self.log.debug("点击搜索框") self.find_and_click(self._serch)
四、pytest+allure生成html报告: