import logging
import time
import traceback
from selenium import webdriver
def log(test_case_func):
def wraps(*args, **keywords):
log_name= time.strftime("%Y%m%d%H%M%S", time.localtime())+test_case_func.__name__
logging.basicConfig(level=logging.INFO,filemode='w',filename='./'+log_name+'.log')
test_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
logging.info(test_time+':现在开始测试:'+test_case_func.__name__)
try:
test_case_func(*args, **keywords)
logging.info(test_time+':测试成功完成!' )
except:
logging.info(test_time+':测试有异常:'+traceback.format_exc())
return wraps
@log
def test_case1(driver):
driver.get('https://www.baidu.com/?tn=sitehao123_15')
driver.maximize_window()
driver.find_element_by_id('kw11')
if __name__ == '__main__':
driver = webdriver.Firefox()
test_case1(driver)
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。