您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。