您好,登錄后才能下訂單哦!
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+':現(xiàn)在開(kāi)始測(cè)試:'+test_case_func.__name__)
try:
test_case_func(*args, **keywords)
logging.info(test_time+':測(cè)試成功完成!' )
except:
logging.info(test_time+':測(cè)試有異常:'+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)
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。