class Evaluationpage(Page): #智能测评 #介绍页 join_loc = PageElement( xpath='//*[@id="root"]/div/div/div[2]/div[3]/a/span') #选择年级 grades = PageElements(xpath='//*[@id="root"]/div/div/ul/li') #下一步 next_loc = PageElement(xpath='//*[@id="root"]/div/div/div[3]/a/span') #题目选项 selects_loc = PageElements( xpath='//*[@id="root"]/div/div/div[2]/div[2]/div') #提交按钮 commit_loc = PageElement(xpath='//*[@id="root"]/div/div/div[4]/a') def start(self): self.join_loc.click() def first_step(self): time.sleep(5) grade = random.choice(self.grades) grade.click() time.sleep(1) self.next_loc.click() def second_step(self): for i in range(20): time.sleep(1) select = random.choice(self.selects_loc) select.click() Evaluationpage(self.driver) self.commit_loc.click()
class LoginPage(Page): server_button=NewPageElement(css=".anticon-setting > svg") server_selector=NewPageElement(xpath="//span[contains(.,'请选择服务器地址')]") testServer_option=NewPageElement(xpath="//div[4]/div") mobileLogin_button=NewPageElement(id_="rc-tabs-0-tab-mobile") mobile_input=PageElements(id_="data0",timeout=2) verificationCode_input=PageElements(id_="data0",timeout=2) login_button=NewPageElement(xpath="//button[@type='submit']")
class ReconciliationPage(Page): '''alert弹框''' basePage_alert = PageElement(xpath="/html/body/div[6]/div/span/div", describe="电子对账提示框") basePage_sure_button = PageElement( xpath="/html/body/div[6]/div/span/div/div/div/span/span/button[2]", describe="确定按钮") '''菜单按钮''' menu_transfer_button = PageElement(xpath="//li[@href='#/Transfer']", describe="转账汇款菜单") menu_account_button = PageElement( xpath="//li[@href='#/AccountManage/AccountQry']", describe="账户信息菜单") menu_batch_button = PageElement( xpath="//li[@href='#/BatchBusinessManage/RosterManager']", describe="批量业务菜单") menu_wsbao_button = PageElement(xpath="//li[@href='#/WSBao']", describe="余利宝菜单") menu_bills_button = PageElement( xpath="//li[@href='#/BillsManage/BillsQry']", describe="工单管理菜单") menu_membermanager_button = PageElement( xpath="//li[@href='#/MemberManage/CompanyInfo']", describe="会员中心菜单") '''#####页面对象#####''' '''首页''' firstPage_reconciliation_link = PageElement( xpath="//*[@data-reactid='.0.0.0.1.1.0.0.$2.0.0']", describe="电子对账") '''对账页''' secondPage_reconciliation_select = PageElement( xpath="//*[@data-reactid='.0.0.0.1.1.0.1.0.0.0.0.1.1.$selection.0']", describe="对账类型") secondPage_reconciliation_select_indexs = PageElements( xpath="//li[@role='menuitem']") secondPage_startDate_button = PageElement( xpath="//input[@data-reactid='.0.0.0.1.1.0.1.0.0.0.1.0.1.0.$=10']", describe="起始时间") secondPage_startDate_table_button = PageElement( xpath="/html/body/div[7]/div/div/div[2]/table/tbody/tr[1]/td[6]/span", describe="2016-1-2") secondPage_endDate_button = PageElement( xpath="//input[@data-reactid='.0.0.0.1.1.0.1.0.0.0.1.0.3.0.$=10']", describe="结束时间") secondPage_endDate_table_button = PageElement( xpath="/html/body/div[8]/div/div/div[2]/table/tbody/tr[2]/td[4]/span", describe="2016-2-7") secondPage_query_button = PageElement( xpath="//*[@data-reactid='.0.0.0.1.1.0.1.0.0.0.1.1.0']", describe="查询") '''同属性元素list''' #list_dolinks = PageElements(class_name="dft margL20 cyan", describe="操作按钮") list_dolinks = PageElements(xpath="//a[@class='dft margL20 cyan']", describe="操作按钮") '''结果页面''' resultPage_msg = PageElement( xpath="//*[@data-reactid='.0.0.0.1.0.0.0.0.0']", describe="反显信息")
class RosterTransfersPage(Page): '''alert弹框''' basePage_alert = PageElement(xpath="/html/body/div[6]/div/span/div", describe="电子对账提示框") basePage_sure_button = PageElement( xpath="/html/body/div[6]/div/span/div/div/div/span/span/button[2]", describe="确定按钮") '''菜单按钮''' menu_transfer_button = PageElement(xpath="//li[@href='#/Transfer']", describe="转账汇款菜单") menu_account_button = PageElement( xpath="//li[@href='#/AccountManage/AccountQry']", describe="账户信息菜单") menu_batch_button = PageElement( xpath="//li[@href='#/BatchBusinessManage/RosterManager']", describe="批量业务菜单") menu_wsbao_button = PageElement(xpath="//li[@href='#/WSBao']", describe="余利宝菜单") menu_bills_button = PageElement( xpath="//li[@href='#/BillsManage/BillsQry']", describe="工单管理菜单") menu_membermanager_button = PageElement( xpath="//li[@href='#/MemberManage/CompanyInfo']", describe="会员中心菜单") '''批量代发-名册代发''' firstPage_fileTransfers_button = PageElement( xpath="//*[@data-reactid='.0.0.0.1.1.0.0.$1.0.0']", describe="批量代发") firstPage_rosterTransfers_button = PageElement( xpath="//*[@data-page='roster_salary']", describe="名册代发") '''名册代发''' firstPage_rosterTransfers_labels = PageElements(xpath="//label/span[2]", describe="单选框list") firstPage_fileSummary_input = PageElement(xpath="//*[@name='fileSummary']", describe="摘要") firstPage_rosters_labels = PageElements(xpath="//div[@class='book-item']", describe="代发名册list") firstPage_next_button = PageElement(xpath="//*[@value='下一步']", describe="下一步") '''代发录入确认页面''' secondPage_verifycode_button = PageElement( xpath="//input[@data-seed='get_verify_code']", describe="获取验证码") secondPage_verifycode_input = PageElement( xpath="//input[@placeholder='请输入验证码']", describe="验证码输入框") secondPage_next_button = PageElement(xpath="//*[@value='下一步']", describe="下一步") '''结果页''' result_msg = PageElement( xpath= "//*[@id='main_content']/div[2]/div/span/div[2]/div[3]/div[2]/span[2]", describe="交易笔数") result_sure_button = PageElement(xpath="//*[@value='返回']", describe="返回按钮")
class OfflinePage(TopLevelPage): top_tab_list = PageElements(xpath='//*[@resource-id="com.transsnet.news.more:id/offline_tab"]/*[1]/*') view_more_btn = PageElement(id_='com.transsnet.news.more:id/view_more_tv') topic_list = PageElements(xpath='//*[@resource-id="com.transsnet.news.more:id/flow_layout"]/*') start_btn = PageElement(id_='com.transsnet.news.more:id/start_btn_container') article_num_btn_1 = PageElement(xpath='//*[@resource-id="com.transsnet.news.more:id/per_channel_title"]/../*[7]') article_num_btn_2 = PageElement(xpath='//*[@resource-id="com.transsnet.news.more:id/per_channel_title"]/../*[8]') article_num_btn_3 = PageElement(xpath='//*[@resource-id="com.transsnet.news.more:id/per_channel_title"]/../*[9]') def to_offline_tab(self): self.top_tab_list[0].click() def to_saved_tab(self): self.top_tab_list[1].click()
class CountrySelectionPage(Page): # delay = 2 # selected_country = PageElement(xpath='//node()[@resource-id="com.transsnet.news.more:id/right_icon"]/../*[2]') container = PageElement(id_='com.transsnet.news.more:id/country_list') country_list = PageElements(id_='com.transsnet.news.more:id/tv_name') oper_index_dict = { '1': 0, # ke '2': 1, # ng '5': 2, # za '3': 3, # eg '8': 4, # gh '9': 5, # ug } def get_country_elem(self, oper_id): index = self.oper_index_dict[str(oper_id)] return self.country_list[index] def change_country(self, oper_id): self.get_country_elem(oper_id).click() def wait_for_loading(self, timeout=20): """ """ start_time = time.time() while True: if self.container is not None: return True elif time.time() - start_time > timeout: break time.sleep(1) return False
class SplashCountryPage(Page): container = PageElement(id_='com.transsnet.news.more:id/country_list') country_list = PageElements(id_='com.transsnet.news.more:id/tv_name') oper_index_dict = { '1': 0, # ke '2': 1, # ng '5': 2, # za '3': 3, # eg '8': 4, # gh '9': 5, # ug } def get_country_elem(self, oper_id): index = self.oper_index_dict[str(oper_id)] return self.country_list[index] def change_country(self, oper_id): self.get_country_elem(oper_id).click() def wait_for_loading(self, timeout=20): """ """ start_time = time.time() while True: if self.container is not None: return True elif time.time() - start_time > timeout: break time.sleep(1) return False
class GuidPage(Page): skip_btn = PageElement(id_='com.transsnet.news.more:id/skip') topic_btn_list = PageElements( xpath= '//*[@id="com.transsnet.news.more:id/recycler"]//*[@id="com.transsnet.news.more:id/name"]' ) confirm_btn = PageElement(id_='com.transsnet.news.more:id/select_btn')
class BaiduPage(Page): search_input = PageElement(id_="kw", describe="搜索框") search_button = PageElement(id_="su", describe="搜索按钮") settings = PageElement(link_text="设置", describe="设置下拉框") search_settings = PageElement(css=".setpref", describe="搜索设置选项") save_settings = PageElement(css=".prefpanelgo", describe="保存设置") search_result = PageElements(xpath="//div/h3/a", describe="搜索结果")
class chooseClassPage(Page): # elem_id = PageElement(id_='id') # elem_name = PageElement(name_='name') # elem_class = PageElement(class_name='class') # elem_tag = PageElement(tag='input') # elem_link_text = PageElement(link_text='this is link') # elem_partial_link_text = PageElement(partial_link_text='is link') # elem_css = PageElement(css='#id') btns_enter_answer = PageElements(xpath='//button[@class="btn bg-primary"]')
class BaiduPage(Page): search_input = PageElement(id_='kw', describe='搜索框') search_button = PageElement(id_='su', describe='搜索按钮') settings = PageElement(link_text='设置', describe='设置下拉框') search_setting = PageElement(css='.setpref', describe='搜索设置选项') save_setting = PageElement(css='.prefpanelgo', describe='保存设置') #定位一组元素 search_result = PageElements(xpath='//div/h3/a', describe='搜索结果')
class Adjustplanpage(Page): #年级 grades = PageElements(class_name='grades_list') #已选能力 active = PageElements(class_name='aspiration_li_active') #能力 abilities = PageElements(xpath='//*[@id="root"]/div/div/div[3]/ul/li') #确认调整 confirm_loc = PageElement(xpath='//*[@id="root"]/div/div/div[4]/a') def adjust(self): grade = random.choice(self.grades) grade.click() for i in range(len(self.active)): self.active[0].click() ability = random.sample(self.abilities, 2) ability[0].click() ability[1].click() self.confirm_loc.click()
class TransfersQueryPage(Page): '''alert弹框''' basePage_alert = PageElement(xpath="/html/body/div[6]/div/span/div", describe="电子对账提示框") basePage_sure_button = PageElement(xpath="/html/body/div[6]/div/span/div/div/div/span/span/button[2]", describe="确定按钮") '''菜单按钮''' menu_transfer_button = PageElement(xpath="//li[@href='#/Transfer']", describe="转账汇款菜单") menu_account_button = PageElement(xpath="//li[@href='#/AccountManage/AccountQry']",describe="账户信息菜单") menu_batch_button = PageElement(xpath="//li[@href='#/BatchBusinessManage/RosterManager']", describe="批量业务菜单") menu_wsbao_button = PageElement(xpath="//li[@href='#/WSBao']", describe="余利宝菜单") menu_bills_button = PageElement(xpath="//li[@href='#/BillsManage/BillsQry']", describe="工单管理菜单") menu_membermanager_button = PageElement(xpath="//li[@href='#/MemberManage/CompanyInfo']", describe="会员中心菜单") '''批量查询''' firstPage_transfersQuery_button = PageElement(xpath="//*[@href='#/BatchBusinessManage/BatchQuery']",describe="批量查询") '''条件录入''' firstPage_trstype_combox = PageElement(xpath="//*[@data-reactid='.0.0.0.1.1.0.1.0.0.0.0.$/=10.$/=11.$/=11']", describe="批量类型") firstPage_trschannel_combox = PageElement(xpath="//*[@data-reactid='.0.0.0.1.1.0.1.0.0.0.0.$/=10.$/=12.$/=11']", describe="交易渠道") firstPage_trsstatus_combox = PageElement(xpath="//*[@data-reactid='.0.0.0.1.1.0.1.0.0.0.0.$/=11.$/=10.$/=11']", describe="处理状态") firstPage_date_combox = PageElements(xpath="//*[@class='ant-calendar-picker-input ant-input ant-input-lg']", describe="日期控件") #firstPage_trschannel_comboxs = PageElement(xpath="//div[data-reactid='.3.0']/ul/li[@role='menuitem']", # describe="交易渠道") firstPage_trstype_comboxs = PageElements(xpath="//ul/li[@role='menuitem']", describe="下拉类型") firstPage_trschannel_comboxs = PageElements(xpath="//ul/li[@role='menuitem']", describe="下拉类型") firstPage_trsstatus_comboxs = PageElements(xpath="//ul/li[@role='menuitem']", describe="下拉类型") firstPage_startdate_tables = PageElements(xpath="//*[@role='gridcell']",describe="开始日期") firstPage_enddate_tables = PageElements(xpath="//*[@role='gridcell']",describe="结束日期") '''代发录入确认页面''' firstPage_download_label = PageElement(xpath="//*[@data-reactid='.0.0.0.1.1.0.1.0.1.1.0.0.1.0.2.$2016041810270000760512.$10.1.0']", describe="下载链接") firstPage_download_link = PageElement(link_text="下载单笔回单") firstPage_query_button = PageElement(xpath="//*[@value='查询']", describe="查询按钮") '''下载页''' secondPage_accountno_input = PageElement(xpath="//*[@id='accountNo']",describe="收款卡号") secondPage_accountame_input = PageElement(xpath="//*[@id='accountName']",describe="收款户名") secondPage_query_button = PageElement(xpath="//*[@value='查询']", describe="查询按钮") secondPage_download_button = PageElements(xpath="//*[@data-seed='batch_item_download_receipt']", describe="回单下载按钮") '''结果确认页面''' thirdPage_sure_button = PageElement(xpath="//*[@value='确定下载']", describe="确定下载") '''结果验证页面''' fourthPage_msg = PageElement(xpath="//*[@class='TrsContFont']", describe="下载成功信息")
class BillQueryPage(Page): '''alert弹框''' basePage_alert = PageElement(xpath="/html/body/div[6]/div/span/div", describe="电子对账提示框") basePage_sure_button = PageElement( xpath="/html/body/div[6]/div/span/div/div/div/span/span/button[2]", describe="确定按钮") '''菜单按钮''' menu_transfer_button = PageElement(xpath="//li[@href='#/Transfer']", describe="转账汇款菜单") menu_account_button = PageElement( xpath="//li[@href='#/AccountManage/AccountQry']", describe="账户信息菜单") menu_batch_button = PageElement( xpath="//li[@href='#/BatchBusinessManage/RosterManager']", describe="批量业务菜单") menu_wsbao_button = PageElement(xpath="//li[@href='#/WSBao']", describe="余利宝菜单") menu_bills_button = PageElement( xpath="//li[@href='#/BillsManage/BillsQry']", describe="工单管理菜单") menu_membermanager_button = PageElement( xpath="//li[@href='#/MemberManage/CompanyInfo']", describe="会员中心菜单") '''首页''' firstPage_billquery_link = PageElement( xpath="//*[@href='#/BillsManage/BillsQry']", describe="工单查询菜单") '''查询页''' firstPage_status_combox = PageElement( xpath="//*[@class='ant-select-selection__rendered']", describe="审批状态") firstPage_status_comboxs = PageElements(xpath="//li[@role='menuitem']", describe="审批状态值") firstPage_date_comboxs = PageElements( xpath="//*[@class='ant-calendar-picker-input ant-input']", describe="日期控件") firstPage_startdate_tables = PageElements( xpath="//*[@class='ant-calendar-cell']", describe="具体日期") firstPage_enddate_tables = PageElements( xpath="//*[@class='ant-calendar-cell']", describe="具体日期") firstPage_query_button = PageElement(xpath="//input[@value='查询']", describe="查询") '''查询结果页''' secondPage_result_list = PageElements(xpath="//*[@class='ant-table-row ']", describe="查询结果列表")
class InterBankTransferpage(Page): '''alert弹框''' firstPage_alert = PageElement(xpath="/html/body/div[6]/div/span/div",describe = "电子对账提示框") firstPage_sure_button = PageElement(xpath="/html/body/div[6]/div/span/div/div/div/span/span/button[2]",describe="确定按钮") '''菜单按钮''' firstPage_menu_button = PageElement(xpath="//li[@href='#/Transfer']",describe="转账菜单") firstPage_intermenu_button = PageElement(xpath="//*[@data-reactid='.0.0.0.1.1.0.1.0.1.1.0.1.1.0.0.$1']",describe="跨行转账") firstPage_alipaymenu_button = PageElement(xpath="//*[@data-reactid='.0.0.0.1.1.0.1.0.1.1.0.1.1.0.0.$2']",describe="支付宝转账") '''转账信息''' '''录入页面''' firstPage_transaccount_input = PageElement(name="payeeAccNo",describe="收款账号") firstPage_transname_input = PageElement(name="payeeAccName",describe="收款账户名") '''收款信息''' firstPage_transbank_index = PageElement(xpath="//input[@data-reactid='.0.0.0.1.1.0.1.0.1.1.0.1.1.1.$0.0.1.0.0.$/=12.$/=10.$/=11.0.$/=10.$selection.0.2.0.0']") firstPage_transbank_indexs = PageElements(xpath="//ul/li[@role='menuitem']",describe="收款银行") firstPage_yhwd_button = PageElement(xpath="//*[@data-seed='dept_show_query_btn']",describe="查询网点") '''网点查询弹框页面''' #secendPage_yhwdkey_input = PageElement(xpath="//input[@data-reactid='.5.$dialog.0.1.0.0.1.0.0']",describe="网点关键字") #id会变化 secendPage_yhwdkey_input = PageElement(xpath="//input[@class='transfer-content-popup-input radius marg0']", describe="网点关键字") secendPage_yhwdkey_button = PageElement(xpath="//input[@value='搜索']",describe="网点搜素") secendPage_yhwdkeyvalue_indexs = PageElements(xpath="//*[@class='bank-item fontz']",describe="网点搜索结果") secendPage_yhwdsure_button = PageElement(xpath="//*[@data-seed='model_ok_btn']",describe="网点搜索确认按钮") secendPage_yhwdkey_result = PageElement(xpath="//p[@data-reactid='.0.0.0.1.1.0.1.0.1.1.0.1.1.1.$0.0.1.0.0.$/=12.$/=11.$/=11.$/=10']",describe="网点反显") '''付款信息''' firstPage_trsamount_button = PageElement(xpath="//*[@name='trsAmount']",describe='转账金额') firstPage_trsamount_types = PageElements(xpath="//*[@class='ant-radio']",describe="到账方式") firstPage_trsamount_index = PageElement(xpath="//span[@data-reactid='.0.0.0.1.1.0.1.0.1.1.0.1.1.1.$0.0.1.0.0.$/=1a.$/=11.0.$/=10.$selection.0']",describe="付款用途") firstPage_trsamount_indexs = PageElements(xpath="//div/ul/li[@role='menuitem']",describe="付款用途列表") firstPage_next_button = PageElement(xpath="//input[@data-seed='cross-next']",describe="下一步") '''转账确认页面''' thirdPage_verifycode_button = PageElement(xpath="//input[@data-seed='get_verify_code']",describe="获取验证码") thirdPage_verifycode_input = PageElement(xpath="//input[@placeholder='请输入验证码']",describe="验证码输入框") sthirdPage_confirm_button = PageElement(xpath="//*[@value='确定']",describe="确定按钮") '''结果页''' confirmPage_return_msg = PageElement(xpath="//*[@data-reactid='.0.0.0.1.1.0.1.0.1.0.1.1']",describe="反显信息")
class HomePage(TopLevelPage): me_icon = PageElement(id_='com.transsnet.news.more:id/me_icon') top_tab_container = PageElement( id_='com.transsnet.news.more:id/tl_tab_news') top_tab_list = PageElements( xpath= '//*[@resource-id="com.transsnet.news.more:id/tl_tab_news"]//*[@resource-id="com.transsnet.news.more:id/tab_name"]' ) channels_entry = PageElement(id_='com.transsnet.news.more:id/tab_settings') article_container = PageElement( id_='com.transsnet.news.more:id/article_recycler') article_tile_list = PageElements( context='article_container', xpath= '//*[@resource-id="com.transsnet.news.more:id/title_1"] | //*[@resource-id="com.transsnet.news.more:id/tv_title"] | //*[@resource-id="com.transsnet.news.more:id/title"]' ) article_source = PageElement(context=True, id_='com.transsnet.news.more:id/source') article_time = PageElement(context=True, id_='com.transsnet.news.more:id/publish_time') article_comment_num = PageElement( context=True, id_='com.transsnet.news.more:id/comment_num') refresh_tips = PageElement( id_='com.transsnet.news.more:id/mid_refresh_text') def next_page(self): container = self.article_container self.swipe_in_element(container, from_y=0.9, to_y=0, delay=1500) time.sleep(1) def get_all_title_text(self): elem_title_list = self.article_tile_list title_text_list = [] for elem_title in elem_title_list: title_text = elem_title.text if title_text: title_text_list.append(title_text) return title_text_list
class AccountManagement(Page): customer_list = PageElement(xpath="/html/body/div/div[1]/div/div[4]/div[1]/div[2]/p", describe="客户列表",timeout=6) add_client = PageElement(name="add", describe="添加客户",timeout=2) input_cname=PageElement(xpath='//*[@name="customerName"]/div[2]/input',describe="输入客户名称",timeout=6) input_phone = PageElement(xpath='//*[@name="phone"]/div[2]/input', describe="输入电话号码") input_city = PageElement(xpath='//*[@name="region"]/div[2]/input', describe="输入省市") customer_level = PageElement(xpath='//*[@name="level"]/span',describe='选择客户级别') customer_level_1 =PageElement(xpath='//*[@name="level"]/div[1]/p[2]',describe='一级客户') pay_type=PageElement(xpath='//*[@name="payType"]/span',describe="付费方式") after_pay = PageElement(xpath='//*[@name="payType"]/div/p[3]',describe="后付费") save =PageElement(class_name='viewC_btnSave',describe="保存",timeout=1) customer_text = PageElements(xpath='//*[@class_name="tbCWrap"]/*',describe="客户列表资料",timeout=1)
class BaiDuPage(Page): """ 百度page层,百度页面封装操作到的元素 """ search_input = PageElement(id_='kw', timeout=10, describe='百度搜索框') search_button = PageElement(id_='su', timeout=5, describe='百度一下按钮') #通过timeout可以添加元素超时时间,默认为10s #通过describe添加元素描述 #定义一组元素 search_result = PageElements(xpath='//div//h3/a') """
class Taskpage(Page): tasks_title = PageElements(class_name='grayColor') logo_loc = PageElements(class_name='finishIcon') cardbtn_loc = PageElement(class_name='cardbtn') def do_task(self): #完成其他线下任务 if self.cardbtn_loc: self.cardbtn_loc.click() for task in self.tasks_title: #print(task) if task.text != '练习题': try: task.click() except: return Taskpage(self.driver).do_task() def get_len(self): if len(self.logo_loc) == 4: return Taskpage(self.driver).get_len() return len(self.logo_loc)
class PayeeQuerypage(Page): '''alert弹框''' firstPage_alert = PageElement(xpath="/html/body/div[6]/div/span/div",describe = "电子对账提示框") firstPage_sure_button = PageElement(xpath="/html/body/div[6]/div/span/div/div/div/span/span/button[2]",describe="确定按钮") '''菜单按钮''' firstPage_menu_button = PageElement(xpath="//li[@href='#/Transfer']",describe="转账菜单") '''#####页面对象#####''' '''录入页面''' firstPage_payeequery_input = PageElement(xpath="//input[@data-reactid='.0.0.0.1.1.0.1.0.1.1.0.0.0.0']",describe="账户搜索框") firstPage_payeequery_lists = PageElements(xpath="//div[@class='card-item-inner ']",describe="搜索结果")
class Exercisepage(Page): #选项元素标签是[2]--[6] question_loc = PageElement(class_name='slick-current') question_list_loc = PageElements(class_name='slick-slide') subit_loc = PageElement(class_name='submit_btn') #selects_loc = PageElement(xpath='/html/body/div[1]/div/div/div[3]/div[1]/div/div/div/div[' + str(x) + ']/div/div/div[3]/span[1]') selects_loc = PageElement(css='.slick-active .option:nth-child(2) > .num') def do_exercise(self): for x in range(0, len(self.question_list_loc)): self.selects_loc.click() time.sleep(2) time.sleep(20) self.subit_loc.click() '''
class Operationpage(Page): #表扬 praise_loc = PageElement(class_name = 'praise_btn') #任务列表 tasks_list_loc = PageElements(class_name = 'unfinished_item') #历史表现 history_loc = PageElement(link_text = '历史表现') def todayplan(self): self.praise_loc.click() def taskslen(self): return len(self.tasks_list_loc) def history(self): self.history_loc.click()
class BillCheckPage(Page): '''alert弹框''' basePage_alert = PageElement(xpath="/html/body/div[6]/div/span/div", describe="电子对账提示框") basePage_sure_button = PageElement( xpath="/html/body/div[6]/div/span/div/div/div/span/span/button[2]", describe="确定按钮") '''菜单按钮''' menu_transfer_button = PageElement(xpath="//li[@href='#/Transfer']", describe="转账汇款菜单") menu_account_button = PageElement( xpath="//li[@href='#/AccountManage/AccountQry']", describe="账户信息菜单") menu_batch_button = PageElement( xpath="//li[@href='#/BatchBusinessManage/RosterManager']", describe="批量业务菜单") menu_wsbao_button = PageElement(xpath="//li[@href='#/WSBao']", describe="余利宝菜单") menu_bills_button = PageElement( xpath="//li[@href='#/BillsManage/BillsQry']", describe="工单管理菜单") menu_membermanager_button = PageElement( xpath="//li[@href='#/MemberManage/CompanyInfo']", describe="会员中心菜单") '''首页''' firstPage_billcheck_link = PageElement( xpath="//*[@href='#/BillsManage/BillsCheck']", describe="工单审批菜单") '''查询页''' firstPage_check_list = PageElements(xpath="//*[@class='ant-checkbox']", describe="审批列表") firstPage_billcheck_button = PageElement( xpath="//*[@data-seed='batch-workbulls-check']", describe="批量审批") '''查询结果页''' secondPage_reject_index = PageElement(xpath="//*[@value='REJECT']", describe="全部拒绝单选框") secondPage_rejecttxt_index = PageElement( xpath="//*[@placeholder='请输入拒绝原因']", describe="拒绝原因") '''验证码验证页面''' secondPage_verifycode_button = PageElement( xpath="//input[@data-seed='get_ve rify_code']", describe="获取验证码") secondPage_verifycode_input = PageElement( xpath="//input[@placeholder='请输入验证码']", describe="验证码输入框") secondPage_next_button = PageElement(xpath="//*[@value='确定']", describe="确定") '''结果页面''' thirdPage_result_msg = PageElement( xpath="//*[@id='content']/div[2]/span/div", describe="反显信息")
class Mainpage(Page): xiaole_loc = PageElement(class_name='enterxiaole') wood_loc = PageElement(class_name='wood') tasks_loc = PageElements(class_name='title') #章节弹框 container_loc = PageElement(class_name='container') choice_loc = PageElement(class_name='am-list-extra') subchoice_loc = PageElement(class_name='am-picker-popup-header-right') click_btn = PageElement(class_name='click_btn') def task(self): return Taskpage(self.driver) def exercise(self): if self.container_loc: self.choice_loc.click() time.sleep(2) self.subchoice_loc.click() time.sleep(2) self.click_btn.click() for task in self.tasks_loc: if task.text == "练习题": task.click() return Exercisepage(self.driver) def exreport(self): for task in self.tasks_loc: if task.text == "练习题": task.click() return Exreportpage(self.driver) def hi_xiaole(self): #小乐同学 self.xiaole_loc.click() return Xiaolepage(self.driver) def woods(self): #学习森林 self.wood_loc.click() return Woodpage(self.driver) def card(self): self.get("http://webapp.leke.cn/leke-ai-pad/#/card") return Cardspage(self.driver)
class AlipayTransferpage(Page): '''alert弹框''' firstPage_alert = PageElement(xpath="/html/body/div[6]/div/span/div", describe="电子对账提示框") firstPage_sure_button = PageElement( xpath="/html/body/div[6]/div/span/div/div/div/span/span/button[2]", describe="确定按钮") '''菜单按钮''' firstPage_menu_button = PageElement(xpath="//li[@href='#/Transfer']", describe="转账菜单") firstPage_intermenu_button = PageElement( xpath="//*[@data-reactid='.0.0.0.1.1.0.1.0.1.1.0.1.1.0.0.$1']", describe="跨行转账") firstPage_alipaymenu_button = PageElement( xpath="//*[@data-reactid='.0.0.0.1.1.0.1.0.1.1.0.1.1.0.0.$2']", describe="支付宝转账") '''转账信息''' '''录入页面''' firstPage_transaccount_input = PageElement(name="payeeAccNo", describe="收款账号") firstPage_transname_input = PageElement(name="payeeAccName", describe="收款账户名") '''付款信息''' firstPage_trsamount_input = PageElement(xpath="//*[@name='trsAmount']", describe='转账金额') firstPage_trsamount_index = PageElement( xpath= "//span[@data-reactid='.0.0.0.1.1.0.1.0.1.1.0.1.1.1.$0.0.1.0.0.$/=1a.$/=11.0.$/=10.$selection.0']", describe="付款用途") firstPage_trsamount_indexs = PageElements( xpath="//div/ul/li[@role='menuitem']", describe="付款用途列表") firstPage_next_button = PageElement( xpath="//input[@data-seed='alipay-next']", describe="下一步") '''转账确认页面''' secondPage_verifycode_button = PageElement( xpath="//input[@data-seed='get_verify_code']", describe="获取验证码") secondPage_verifycode_input = PageElement( xpath="//input[@placeholder='请输入验证码']", describe="验证码输入框") secondPage_confirm_button = PageElement(xpath="//*[@value='确定']", describe="确定按钮") '''结果页''' confirmPage_return_msg = PageElement( xpath="//*[@data-reactid='.0.0.0.1.1.0.1.0.1.0.1.1']", describe="反显信息")
class BaiduPage(Page): search_input = PageElement(id_="kw", describe="搜索框") search_button = PageElement(id_="su", describe="搜索按钮") settings = PageElement(xpath='//*[@id="s-usersetting-top"]', describe="设置下拉框") search_setting = PageElement(css=".setpref", describe="搜索设置选项") save_setting = PageElement(css=".prefpanelgo", describe="保存设置") # 定位一组元素 search_result = PageElements(xpath="//div/h3/a", describe="搜索结果") def search_succes(self, values): self.search_input = values self.search_button.click() def baidu_seeting(self): self.settings.click() self.search_setting.click() time.sleep(2) self.save_setting.click()
class BaiduPage(Page): ''' 'css': By.CSS_SELECTOR, 'id_': By.ID, 'name': By.NAME, 'xpath': By.XPATH, 'link_text': By.LINK_TEXT, 'partial_link_text': By.PARTIAL_LINK_TEXT, 'tag': By.TAG_NAME, 'class_name': By.CLASS_NAME, ''' search_input = PageElement(id_="kw", describe="搜索框") search_button = PageElement(id_="su", describe="搜索按钮") #settings = PageElement(link_text="设置", describe="设置下拉框",timeout=10) settings = PageElement(id_="s-usersetting-top", describe="设置下拉框", timeout=10) search_setting = PageElement(link_text="搜索设置", describe="搜索设置选项") #save_setting = PageElement(css=".prefpanelgo", describe="保存设置") save_setting = PageElement(xpath="//a[text()='保存设置']", describe="保存设置") # 定位一组元素 search_result = PageElements(xpath="//div/h3/a", describe="搜索结果")
class ResultPage(Page): # 定位一组元素 search_result = PageElements(xpath="//div/h3/a")
class JSPage(Page): frame = PageElement(id_="iframe") date = PageElement(id_="appDate") year_mouth_data = PageElements(css=".dwwo")
class Cardspage(Page): cards_list_loc = PageElements(class_name='item') def get_cards_num(self): return len(self.cards_list_loc)