#生成测试报告
from selenium import webdriver
import unittest
import time
import HTMLTestRunner
class test_class(unittest.TestCase):
def setUp(self):
self.verificationErrors=[]
self.test=webdriver.Ie()
self.url="http://192.168.0.39"
def test_login(self):
pa=self.test
pa.get(self.url)
user=pa.find_element_by_id('username')
user.send_keys('system')
passwd=pa.find_element_by_id('password')
passwd.send_keys('123456')
pa.execute_script('loginsubmit()')
time.sleep(10)
def tearDown(self):
pass
if __name__=="__main__":
testsuite=unittest.TestSuite()
testsuite.addTest(test_class("test_login"))
filename="e:\result.html"
fp=file(filename,'wb')
runner=HTMLTestRunner.HTMLTestRunner(stream=fp,title='Result',description='Test_Report')
runner.run(testsuite)