#coding=utf-8
from selenium import webdriver
#from selenium.webdriver.common.keys import Keys
import unittest,time
from public import login #导入login文件
import HTMLTestRunner #引入HTMLTestRunner包
class TestSendEmail(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
self.driver.maximize_window()
self.driver.implicitly_wait(20)
self.base_url = "https://mail.163.com/"
self.verificationErrors = []
#只输入收件人发送
def test_del(self):
driver = self.driver
driver.get(self.base_url)
#登录
login.login(self,'alyna_cai','QQqq1122369')
time.sleep(2)
#进入收件箱
driver.find_element_by_class_name('nui-tree-item-text').click()
time.sleep(2)
#勾选第一封邮件,作为删除对象
driver.find_elements_by_xpath('//span[@class="nui-chk-symbol"]/b').pop(1).click()
time.sleep(2)
#选择‘删除’按钮
driver.find_element_by_xpath('//*[@class="frame-main-cont-head"]/div/div[2]/div/span').click()
time.sleep(2)
#断言是否已删除
text = driver.find_element_by_css_selector("span.nui-tips-text>a").text
#print(text)
self.assertEqual(text,u'已删除')
#time.sleep(5)
#退出
login.logout(self)
def tearDown(self):
self.driver.quit()
self.assertEqual([],self.verificationErrors)
if __name__ == "__main__":
unittest.main()
'''
testunit = unittest.TestSuite()
testunit.addTest(TestSendEmail('test_del')) #添加测试用例到测试套件中
#获取当前时间
now = time.strftime("%Y-%m-%d %H_%M_%S")
#定义个报告存放路径
filename = 'D:\\python\\test_163email\\test_case\\report\\'+now+' delete_result.html'
fp = open(filename,'wb')
#定义测试报告
runner = HTMLTestRunner.HTMLTestRunner(
stream = fp,
title = u'163邮件删除测试报告',
description = u'用例执行情况:'
)
#运行测试用例
runner.run(testunit)
fp.close()'''
网友评论