def input_string(localtion, content, *args): try: ele_object = find.getElement(localtion) ele_object.clear() ele_object.send_keys(content) except Exception as e: raise e
def click_SvgelementXpath(localtion, seconds=None): try: Svgelement = find.getElement(localtion) action = ActionChains(get_selenium()) action.click(Svgelement).perform() except Exception as e: raise e
def get_order_discount(): #获取订单列表优惠金额 # table_tagname=find.getElement_tag_name('table') #获取表格标签 table_tagname = find.getElement( read_file.get_option('workbench', 'table_real_pay')) table_element = Table.Table(table_tagname).getCell(rowNo=2, colNo=7) #获取表格指定的单元格对象 return table_element.text #返回指定单元格对象的文本 PageAction.pause(2)
def get_order_realpay(): #获取订单列表实收金额 # 方法 1:return Action.getelement_text(locatorMethod='xpath',localExpression='//tbody[@class="ant-table-tbody"]/tr[1]/td[6]') # table_tagname=find.getElement_tag_name('table') #获取表格标签 table_tagname = find.getElement( read_file.get_option('workbench', 'table_real_pay')) table_element = Table.Table(table_tagname).getCell(rowNo=2, colNo=6) #获取表格指定的单元格对象 return table_element.text #返回指定单元格对象的文本 PageAction.pause(2)
def login(): # helper.open_browser('chrome') # helper.open_url() #从配置读取用户信息 userName = Parse_JYH_Config().get_option(sectionName='account_info', option='station_username') #输入用户名 PageAction.input_string(read_file.get_option('login', 'userName'), content=userName) password = Parse_JYH_Config().get_option(sectionName='account_info', option='station_password') # 输入密码 PageAction.input_string(read_file.get_option('login', 'password'), content=password) # 输入验证码 txtCode = Parse_JYH_Config().get_option(sectionName='account_info', option='txtCode') PageAction.input_string(read_file.get_option('login', 'txtCode'), content=txtCode) #点击登录 PageAction.click(read_file.get_option('login', 'login_button')) #校验页面元素,左侧侧边栏文本包含'工作台' find.getElement(read_file.get_option('login', 'workbench'), seconds=14) print('账号%s登录成功!' % (userName))
def click(localtion, *args): try: ele_object = find.getElement(localtion) ele_object.click() except Exception as e: raise e
def getelement_text(localtion, *args): try: text_value = find.getElement(localtion).text return text_value except Exception as e: raise e
def getelement_attribute(localtion, attr, *args): try: attr_value = find.getElement(localtion).get_attribute(attr) return attr_value except Exception as e: raise e
def enter_workbenchpage(): # login.login() find.getElement( localtion=read_file.get_option('workbench', 'workbench_text')) print('当前位置:工作台首页')
def find_pop(): PageAction.pause(2) find.getElement(read_file.get_option('workbench', 'tan'))