def clear_input(self,element_info): element=self.find_element(element_info) logger.info('[%s]元素输入框操作清空' % (element_info['element_name'])) element.clear()
def input(self, element_info, content): element = self.find_element(element_info) element.send_keys(content) logger.info('[%s]元素输入内容:%s' % (element_info['element_name'], content))
def click_save_project_button(self): self.scroll_to_element(self.project_save_button) self.click(self.project_save_button) logger.info("点击保存项目按钮")
def set_browser_min(self): self.driver.minimize_window() logger.info('设置浏览器最小化')
def get_title(self): value = self.driver.title logger.info('获取网页标题,标题是%s' % value) return value
def get_row_count(self): row_count = self.sheet_data.nrows logger.info("Excel有:%s行" % row_count) return row_count
def open_url(self, url): self.driver.get(url) logger.info('打开url地址 %s ' % url)
def switch_window_by_url(self,url): for handle in self.driver.window_handles: self.driver.switch_to.window(handle) if self.driver.current_url.__contains__(url): break logger.info('切换到URL为[%s]的句柄成功!' % url)
def close_tab(self): self.driver.close() logger.info('关闭当前的tab页签')
def open_url(self,url): self.driver.get(url) logger.info('打开URL地址%s;'%url)
def switch_window_by_title(self,title): for handle in self.driver.window_handles: self.driver.switch_to.window(handle) if self.driver.title.__contains__(title): break logger.info('切换到网页标题为[%s]的句柄成功!'%title)
def switch_to_frame_by_element(self,element_info): element = self.find_element(element_info) self.driver.switch_to.frame(element) logger.info('[%s]frame元素切换成功' % (element_info["element_name"]))
def ctrl_v(self,element_info): element=self.find_element(element_info) logger.info('[%s]元素输入框内容进行粘贴操作' % (element_info['element_name'])) element.send_keys(Keys.CONTROL, 'v')
def enter(self,element_info): element=self.find_element(element_info) logger.info('[%s]元素进行回车键操作' % (element_info['element_name'])) element.send_keys(Keys.ENTER)
def tearDown(self) -> None: self.session.close() logger.info('---------用户管理执行完毕-----------')
def set_brower_min(self): self.driver.minimize_window() logger.info("设置浏览器的最小化")
def click_login(self): self.click(self.login_button) logger.info('点击登录')
def brower_refresh(self): self.driver.refresh() logger.info("浏览器的刷新操作")
def get_col_count(self): col_count = self.sheet_data.ncols logger.info("Excel有:%s列" % col_count) return col_count
def get_title(self): value=self.driver.title logger.info("获取网页的标题为:%s"%value) return value
def set_browser_max(self): self.driver.maximize_window() logger.info('设置浏览器最大化')
def quit_brower(self): self.driver.quit() logger.info("关闭浏览器")
def refresh(self): self.driver.refresh() logger.info('浏览器刷新操作')
def get_element_attribute(self,element_info,attribute_name): element=self.find_element(element_info) value=element.get_attribute(attribute_name) logger.info('[%s]元素的%s的值为:%s'%(element_info['element_name'],attribute_name,value)) return value
def click(self, element_info): element = self.find_element(element_info) element.click() logger.info('[%s]元素进行点击操作' % element_info['element_name'])
def get_text(self,element_info): text=self.find_element(element_info).text logger.info('[%s]元素的text值为:%s'%(element_info['element_name'],text)) return text
def input_start_end_date(self): self.click(self.start_end_date) logger.info("选择起始日期=一星期")
def setUp(self) -> None: self.hosts = config.HOSTS # 方式一 self.session = requests.session() logger.info('---------用户管理开始执行-----------')
def click_add_task_button(self): self.click(self.add_task_button) logger.info("点击新增任务按钮")
def back_space(self,element_info): element=self.find_element(element_info) logger.info('[%s]元素操作back_space' % (element_info['element_name'])) element.send_keys(Keys.BACK_SPACE)