selenium3关于ddt驱动之读取json文件。。。
1 from selenium import webdriver 2 import ddt 3 import time 4 import unittest 5 6 """ 7 DDT(驱动.json文件) 8 """ 9 10 11 @ddt.ddt 12 class TestLogin(unittest.TestCase): 13 14 @classmethod 15 def setUpClass(cls): 16 cls.driver = webdriver.Chrome() 17 cls.url = "http://192.168.117.9:8080/jforum/forums/list.page" 18 19 def LoginFunc(self, name, password): 20 self.driver.get(self.url) 21 self.driver.find_element_by_name('username').send_keys(name) 22 self.driver.find_element_by_name('password').send_keys(password) 23 time.sleep(1) 24 self.driver.find_element_by_name('login').click() 25 time.sleep(2) 26 self.driver.find_element_by_id('logout').click() 27 28 @ddt.file_data('ddt_data.json') 29 def test_case1(self, name, password): 30 self.LoginFunc(name, password) 31 32 @classmethod 33 def tearDownClass(cls): 34 cls.driver.quit() 35 36 37 if __name__ == "__main__": 38 unittest.main()
.json结尾,前面是测试用例名