def test_addaccount_001( self, action: ElementActions, account_name, ): self.sub_into_account(action) self.sub_into_cash(action) # action.input_text(self.add_account.account_name,data.addaccount_001.get('params').get('account')) action.input_text(self.add_account.account_name, account_name) action.click(self.add_account.create)
def test_addaccount_002(self, action: ElementActions): # action.click(Account.add_account.account) self.sub_into_account(action) action.click(self.add_account.add) action.click(self.add_account.cash) action.input_text(self.add_account.account_name, data.addaccount_002.get('params').get('account')) action.click(self.add_account.create)
def check_page(Pages, action: ElementActions): #只能检测静态页面,即有固定进入方法的:pageinto pagesname_list = get_attrsname(Pages) for page_name in pagesname_list: page = getattr(Pages, page_name) #如果为静态页面时可通过page的跳转方法进入对应页面 if hasattr(page, 'pageinto') == False: continue else: log.info(' ----检测静态页面: {}----'.format(page_name)) elements_name = get_attrsname(page) getattr(page, 'pageinto')(action) # 对元素进行遍历查询 for element_name in elements_name: element = getattr(page, element_name) if isinstance(element, dict): if element.get('dynamic') == False: if element.get('switch') != None: #如果该元素在当前页面有前置步骤,则执行该前置步骤 getattr(page, element.get('switch'))(action) action.is_element_exist(locator=element)
def action(driverenv): element_action = ElementActions(driverenv) yield element_action #返回并且挂载ElementActions的实例,在对应作用域结束前,执行driver.quit() element_action.driver.quit()