python+ddt数据驱动实战

tech2022-12-16  98

import unittest from selenium import webdriver import time from ddt import ddt,data @ddt class Fortest(unittest.TestCase): # 打开谷歌浏览器,打开百度网页 def setUp(self): self.driver = webdriver.Chrome() self.driver.get("http://www.baidu.com") # 关闭浏览器 def tearDown(self): time.sleep(3) self.driver.quit() # 在百度中查询selenium 和 python @data('selenium',"python") def test_1(self,txt): self.driver.find_element_by_id("kw").send_keys(txt) time.sleep(1) self.driver.find_element_by_id("su").click() if __name__ == "__main__": unittest.main()
最新回复(0)