def login(driver): driver.maximize_window() driver.find_element(By.ID, "eid").click() driver.find_element(By.ID, "eid").send_keys("wq") driver.find_element(By.ID, "btnSubmit").click() time.sleep(5) return driver
载入使用
def test_addtip(self): # login driver = self.driver driver.get(self.base_url) time.sleep(2) login(driver) time.sleep(2)
用例执行前后
@classmethod def setUpClass(self): self.driver = webdriver.Chrome() self.base_url = "www.baidu.com" self.vars = {} @classmethod def tearDownClass(cls): cls.driver.quit()