zoukankan      html  css  js  c++  java
  • unittest中的Empty suite错误

    import unittest
    from selenium import webdriver
    
    
    class ibdata(unittest.TestCase):
        @classmethod
        def setUpClass(cls):
            cls.driver = webdriver.Chrome()
            cls.driver.maximize_window()
            cls.driver.implicitly_wait(30)
            cls.driver.get("http://www.ibdata.cn/#!/login")
    
        @classmethod
        def tearDownClass(self):
            self.driver.quit()
    
        def ibdata_login(self):
            self.driver.find_element_by_xpath("/html/body/div/div/div[2]/div/div[1]/div[2]/div/div[2]/div[1]/div[1]/div/input").send_keys("xxxxxx")
            self.driver.find_element_by_xpath("/html/body/div/div/div[2]/div/div[1]/div[2]/div/div[2]/div[1]/div[2]/div/input").send_keys("xxxxx")
            self.driver.find_element_by_xpath("/html/body/div/div/div[2]/div/div[1]/div[2]/div/div[2]/div[2]/button").click()
    
        def ibdata_search(self):
            pass
    
    
    if __name__ == "__main__":
        unittest.main()
    

      运行后显示:

    我的解决办法是:测试用例以test开头,完美解决

    class ibdata(unittest.TestCase):
        @classmethod
        def setUpClass(cls):
            cls.driver = webdriver.Chrome()
            cls.driver.maximize_window()
            cls.driver.implicitly_wait(30)
            cls.driver.get("http://www.ibdata.cn/#!/login")
    
        @classmethod
        def tearDownClass(self):
            self.driver.quit()
    
        def test_login(self):
            self.driver.find_element_by_xpath("/html/body/div/div/div[2]/div/div[1]/div[2]/div/div[2]/div[1]/div[1]/div/input").send_keys("1xxxx")
            self.driver.find_element_by_xpath("/html/body/div/div/div[2]/div/div[1]/div[2]/div/div[2]/div[1]/div[2]/div/input").send_keys("9xxxxg")
            self.driver.find_element_by_xpath("/html/body/div/div/div[2]/div/div[1]/div[2]/div/div[2]/div[2]/button").click()
    
        def test_search(self):
            pass
    
    
    if __name__ == "__main__":
        unittest.main()
    

  • 相关阅读:
    正则:连续数字
    [f]聊天的时间格式化
    微信物理返回刷新页面
    npm 使用记录
    Java内存可见性volatile
    EA通过MySQL多人协作
    Sonarqube Webhook自定义参数
    使用阿里云加速Docker镜像下载
    Java异常堆栈丢失的现象及解决方法
    fo-dicom库 Dicom.Native.dll如何自动到编译输出目录
  • 原文地址:https://www.cnblogs.com/1510152012huang/p/10685095.html
Copyright © 2011-2022 走看看