""" used parameterized test """ @parameterized.expand([ (1, 'pyse'), (2, 'selenium'), (3, 'unittest'), ]) def test_baidu(self, name, search_key): ''' baidu search key : pyse ''' self.open("https://www.baidu.com") self.clear("id=>kw") self.type("id=>kw", search_key) self.click("css=>#su") self.assertTitle(search_key) if __name__ == '__main__': runner = TestRunner('./', '百度测试用例', '测试环境:Firefox') runner.debug() ''' 说明: './' : 指定测试目录。 '百度测试用例' : 指定测试项目标题。 '测试环境:Chrome' : 指定测试环境描述。 debug() # debug模式不生成测试报告 run() # run模式生成测试报告 '''
from pyse import Pyse, TestCase, TestRunner import sys, pprint pprint.pprint(sys.path) from object.page import Baidu_page class BaiduTest(TestCase): ''' Baidu serach test case''' @classmethod def setUpClass(cls): cls.driver = Pyse("chrome") def test_case(self): ''' baidu search key : pyse ''' bd = Baidu_page.BaiduPage(self.driver) bd.open() bd.search_input("pyse") bd.search_button() self.assertTitle("pyse_百度搜索") if __name__ == '__main__': runner = TestRunner() runner.debug() # debug 模拟不会生成测试报告