def test_05(self, **kwargs): self.driver = webdriver.Chrome(options=Options().conf_option()) self.driver.implicitly_wait(10) self.driver.get(kwargs['url']) self.driver.find_element_by_id('kw').send_keys(kwargs['txt']) self.driver.find_element_by_id('su').click() sleep(5) self.driver.quit()
def open_browser(browser_type): try: if browser_type == 'CHR': global driver driver = webdriver.Chrome(options=Options().options_conf()) else: driver = getattr(webdriver, browser_type)() except Exception as e: driver = webdriver.Chrome() return driver
def open_browser(browser_type): try: if browser_type == 'CHR': Logger().log().info('正常启动浏览器中......') driver = webdriver.Chrome(options=Options().options_conf()) else: driver = getattr(webdriver, browser_type)() except Exception as e: Logger().log().info("输入浏览器类型错误,默认调用谷歌浏览器,错误信息{}".format(e)) driver = webdriver.Chrome() return driver
def open_brower(browser_type): #添加异常处理 try: if browser_type == 'Chrome': log.info("chrome浏览器初始化,正在登陆中...") driver = webdriver.Chrome(options=Options().conf_option()) else: log.info("非chrome开启,正在登陆中...") driver = getattr(webdriver, browser_type)() except: log.info("默认浏览器开启,正在登陆中...") driver = webdriver.Chrome() return driver
def browser_type(type): type = type.upper() if type == "CHR": Logger().log().info('正常启动谷歌浏览器中......') driver = webdriver.Chrome(options=Options().options_conf()) elif type == "IE": Logger().log().info('正常启动IE浏览器中......') driver = webdriver.Ie() elif type == "FF": Logger().log().info('正常启动火狐浏览器中......') driver = webdriver.Firefox() else: Logger().log().info('输入浏览器类型失败,默认启用chrome浏览器') driver = webdriver.Chrome() return driver
#断言元素 #元素操作 def input_user(self, txt): self.locator(self.user).send_keys(txt) def input_pwd(self, txt): self.locator(self.pwd).send_keys(txt) def click_xuyi(self): self.locator(self.xuyi).click() def click_registar(self): self.locator(self.registar).click() #断言方法 if __name__ == '__main__': # 调试 options = Options().conf_option() driver = webdriver.Chrome(options=options) lp = registarPage(driver=driver, url=registarPage.url) lp.visit() lp.input_user('wunongzhong') lp.input_pwd('111111') lp.click_xuyi() lp.click_registar() lp.quit()