|
本帖最后由 鹿小诞 于 2017-5-18 14:25 编辑
已解决,我自己写错了。 大家请无视
#coding=utf-8
from selenium import webdriver
import time
import os
import datetime
import logging
import traceback
#测试登录系统是否成功函数
def _Login_(username,password):
#输入用户名密码
driver.find_element_by_name('username').clear()
driver.find_element_by_name('username').send_keys(username)
driver.find_element_by_name('psword').clear()
driver.find_element_by_name('psword').send_keys(password)
driver.find_element_by_name('submitBtn').click()
#验证是否登录成功
time.sleep(10)
currenturl = driver.current_url
if currenturl == "http://10.188.181.74:9082/webnc2-webapp/index-metro2016.html1" :
print("登录成功!")
else:
_WriteLog_(r"E:\自动化测试\test\登录客反.py")
#写入日志函数
def _WriteLog_(filename):
# 构造文件名:basename获取文件名.后缀。splitext分离文件名及后缀名 basenmae+当前时间
logname = os.path.splitext(os.path.basename(filename))[0] + datetime.datetime.now().strftime("%Y%m%D%H%M%S") + ".log"
logging.basicConfig(filename=logname)
s = traceback.format_exc()
logging.error(s)
driver = webdriver.Chrome()
driver.get("http://10.188.181.74:9082/sso-webapp")
#登录系统
_Login_("zhulj","1")
为什么运行了报错:[size=15.0667px]Traceback (most recent call last): File "E:/自动化测试/test/登录客反.py", line 53, in <module> _Login_("zhulj","1") File "E:/自动化测试/test/登录客反.py", line 34, in _Login_ _WriteLog_(r"E:\自动化测试\test\登录客反.py") File "E:/自动化测试/test/登录客反.py", line 41, in _WriteLog_ logging.basicConfig(filename=logname) File "C:\Users\sunl\AppData\Local\Programs\Python\Python36\lib\logging\__init__.py", line 1781, in basicConfig h = FileHandler(filename, mode) File "C:\Users\sunl\AppData\Local\Programs\Python\Python36\lib\logging\__init__.py", line 1030, in __init__ StreamHandler.__init__(self, self._open()) File "C:\Users\sunl\AppData\Local\Programs\Python\Python36\lib\logging\__init__.py", line 1059, in _open return open(self.baseFilename, self.mode, encoding=self.encoding)FileNotFoundError: [Errno 2] No such file or directory: 'E:\\自动化测试\\test\\登录客反20170505\\18\\17135258.log'[size=15.0667px]
[size=15.0667px]求问不知道哪里出问题了
|
|