51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2017|回复: 2
打印 上一主题 下一主题

python用例執行添加測試報告報錯。請問為什麼?

[复制链接]
  • TA的每日心情

    2016-3-9 11:58
  • 签到天数: 51 天

    连续签到: 1 天

    [LV.5]测试团长

    跳转到指定楼层
    1#
    发表于 2015-9-10 14:17:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    1. # -*- coding: utf-8 -*-
    2. from selenium import webdriver
    3. from selenium.webdriver.common.by import By
    4. from selenium.webdriver.common.keys import Keys
    5. from selenium.webdriver.support.ui import Select
    6. from selenium.common.exceptions import NoSuchElementException
    7. import unittest, time, re
    8. import HTMLTestRunner

    9. class Baidu(unittest.TestCase):
    10.     def setUp(self):
    11.         self.driver = webdriver.Firefox()
    12.         self.driver.implicitly_wait(30)
    13.         self.base_url = "http://www.591.com.tw/"
    14.         self.verificationErrors = []
    15.         self.accept_next_alert = True
    16.    
    17.     def test_baidu(self):
    18.         driver = self.driver
    19.         driver.get(self.base_url + "/index.php?module=userCenter&action=newHost")
    20.         driver.find_element_by_link_text(u"物件管理").click()
    21.         driver.find_element_by_link_text(u"關閉中的物件").click()
    22.    
    23.     def is_element_present(self, how, what):
    24.         try: self.driver.find_element(by=how, value=what)
    25.         except NoSuchElementException, e: return False
    26.         return True
    27.    
    28.     def is_alert_present(self):
    29.         try: self.driver.switch_to_alert()
    30.         except NoAlertPresentException, e: return False
    31.         return True
    32.    
    33.     def close_alert_and_get_its_text(self):
    34.         try:
    35.             alert = self.driver.switch_to_alert()
    36.             alert_text = alert.text
    37.             if self.accept_next_alert:
    38.                 alert.accept()
    39.             else:
    40.                 alert.dismiss()
    41.             return alert_text
    42.         finally: self.accept_next_alert = True
    43.    
    44.     def tearDown(self):
    45.         self.driver.quit()
    46.         self.assertEqual([], self.verificationErrors)

    47. if __name__ == "__main__":

    48.     testunit=unittest.TestSuite()

    49.     testunit.addTest(Baidu("test_baidu_search"))
    50.    

    51.     filename = 'E:\\selenium_use_case\\report\\result.html'
    52.     fp = file(filename,'wb')

    53.     runner =HTMLTestRunner.HTMLTestRunner(stream=fp,
    54.         title=u'百度搜索测试报告',
    55.         description=u'用例执行情况:')

    56.     runner.run(testunit)
    57.    
    复制代码


    1. Traceback (most recent call last):
    2.   File "E:/selenium_use_case/test_case/baidu.py", line 54, in <module>
    3.     testunit.addTest(Baidu("test_baidu_search"))
    4.   File "E:\python27\lib\unittest\case.py", line 189, in __init__
    5.     (self.__class__, methodName))
    6. ValueError: no such test method in <class '__main__.Baidu'>: test_baidu_search
    复制代码

    報錯日誌。。
    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    昨天 07:19
  • 签到天数: 2773 天

    连续签到: 4 天

    [LV.Master]测试大本营

    2#
    发表于 2015-9-11 09:42:22 | 只看该作者
    报错,没这个方法

    评分

    参与人数 1测试积点 +10 收起 理由
    lsekfe + 10 恭喜你获得测试积点10

    查看全部评分

    回复 支持 反对

    使用道具 举报

    该用户从未签到

    3#
    发表于 2015-10-16 17:34:32 | 只看该作者
    test_baidu_search你脚本里面没这个测试方法啊?
    而且unittest框架里面测试方法要test开头
    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-9-22 04:28 , Processed in 0.075687 second(s), 23 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表