def set_Firefox_driver(self): conf = ConfigUtils() driver = webdriver.Firefox() driver.implicitly_wait(10) driver.maximize_window() url = conf.get_zentao_url driver.get(url) return driver
def set_Chrome_driver(): chrome_options = Options() # 谷歌文档提到需要加上这个规避bug chrome_options.add_argument('--disable-gpu') # 设置默认编码为utf-8 chrome_options.add_argument('lang=zh_CN.UTF-8') # 取消chrome受自动化软件控制提示 chrome_options.add_experimental_option('useAutomationExtension', False) #取消chrome受自动化软件控制提示 chrome_options.add_experimental_option("excludeSwitches", ['enable-automation']) conf = ConfigUtils() driver = webdriver.Chrome(options=chrome_options) driver.implicitly_wait(10) driver.maximize_window() url = conf.get_zentao_url driver.get(url) return driver
# self.keeplogin_checkbox = self.driver.find_element(By.XPATH, '//input[@id="keepLoginon"]') # 方法-》控件的操作 # 输入用户名 def input_username(self, username): # self.username_inputbox.send_keys(username) # logger.info('用户名输入框输入:'+ str(username)) self.input(self.username_inputbox, username) # 输入密码 def input_password(self, password): # self.password_inputbox.send_keys(password) # logger.info('密码输入框输入:'+str(password)) self.input(self.password_inputbox, password) # 点击登录按钮 def click_login(self): # self.login_button.click() # logger.info("点击登录按钮成功") self.click(self.login_button) if __name__ == "__main__": # 用例1:登录成功用例 conf = ConfigUtils() driver = Set_Driver.set_Chrome_driver() login.test_login(conf.get_zentao_url, conf.get_username, conf.get_password, driver) time.sleep(3)