TA的每日心情 | 难过 2014-12-30 12:05 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]测试小兵
|
以下是代码:
#coding=utf-8
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re
import HTMLTestRunner
class Baidu(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "http://www.baidu.com/"
self.verificationErrors = []
self.accept_next_alert = True
def test_baidu_search(self):
driver = self.driver
driver.get(self.base_url + "/")
driver.find_element_by_id("kw").send_keys("selenium webdriver")
driver.find_element_by_id("su").click()
time.sleep(2)
driver.close()
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
testunit = unittest.TestSuite()
testunit.addTest(Baidu("test_baidu_search"))
filename = "E:\\python\\code_selenium\\reports\\result1.html"
fp = file(filename, 'wb')
runner = HTMLTestRunner.HTMLTestRunner(stream=fp,
title=u'百度搜索测试报告',
description=u'用例执行情况:')
runner.run(testunit)
那么问题来了:
为什么我用pychram执行脚本,不生成测试报告
用idle执行脚本却可以生成测试报告
求大神解答
|
|