测试断言常用方法
其中assertIsInstance,测试obj是不是cls的实例(它可以是类或类的元组,如isinstance() 支持。检查具体类型使用assertIs(type(obj),cls))
import unittest
from time import sleep
from boss_job.temp2 import InitTest
from boss_job import for_all
class Zxw_Test(InitTest):
def test_design_program(self):
self.webdr.find_element_by_link_text("程序设计").click()
sleep(3)
self.assertEqual(self.webdr.title,"程序开发-我要自学网") #断言
self.webdr.find_element_by_css_selector("a.node:nth-child(14)")
sleep(5)
self.webdr.get(self.test_url)
print("测试程序设计")
def test_search(self):
self.webdr.find_element_by_id("keyWordsT").send_keys("python")
sleep(3)
self.webdr.find_element_by_css_selector(".Hui-iconfont-search2").click()
sleep(4)
self.assertEqual(self.webdr.title,"网站搜索-我要自学网") # 断言
self.webdr.get(self.test_url)
print("测试搜索")
if __name__ == '__main__':
suit = unittest.TestLoader().loadTestsFromModule(for_all)
unittest.TextTestRunner(verbosity=2).run(suit)