如何把python运行结果保存到log文件,我运行下面代码 log文件为空?谢谢!
# coding = utf-8import os
path = "E:\\python\\case"
caselist = os.listdir(path)
for n in caselist:
s = n.split('.')
if s =='py':
os.system('E:\\python\\case\\%s >>E://log.txt' %n)
用例代码:
# coding = utf-8
from selenium import webdriver
import time,unittest
class scroll(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
self.driver.implicitly_wait(10)
self.driver.maximize_window()
self.url = "http://www.baidu.com"
def test_baidu_scroll(self):
driver = self.driver
driver.get(self.url)
time.sleep(3)
driver.find_element_by_id("kw").send_keys("selenim")
driver.find_element_by_id("su").click()
driver.implicitly_wait(10)
time.sleep(2)
driver.quit()
if __name__=="__main__":
unittest.main()
页:
[1]