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()

  运行后显示:

unittest中的Empty suite错误 随笔 第1张

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

我的解决办法是:测试用例以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()

unittest中的Empty suite错误 随笔 第2张

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄