def get_phone_num( self ): """ :return:获取当前用户的手机号 """ publicPage = PublicPage( self.driver ) num_loc = self.driver.find_element_by_id( phone_elem ) publicPage.get_value( num_loc )
def get_modal_body_text( self ): """ :return:弹窗提示内容 """ publicPage = PublicPage(self.driver) text_loc = self.driver.find_element_by_xpath(modal_body_text_elem) publicPage.get_value(text_loc)
def get_modal_title( self ): """ :return:弹窗标题 """ publicPage = PublicPage(self.driver) title_loc = self.driver.find_element_by_css_selector(modal_title_elem) publicPage.get_value(title_loc)
def get_list_total(self): try: publicPage = PublicPage(self.driver) elem_loc = self.driver.find_element_by_xpath( list_base_elem + self.invoice_io + list_total_elem) publicPage.get_value(elem_loc) except Exception as e: print('[InvoiceListPage]get_list_total--获取' + page_name + '总额失败,失败原因是=', str(e))
def get_comp_name(self): """ :return:获取当前帐套名称 """ publicPage = PublicPage(self.driver) text_loc = self.driver.find_element_by_xpath(comp_name_elem) return publicPage.get_value(text_loc)
def get_login_user_name(self): """ :return:登陆用户用户名称 """ publicPage = PublicPage(self.driver) name_loc = self.driver.find_element_by_xpath(login_user_name_elem) return publicPage.get_value(name_loc)
def get_account_company_name(self): """ :return:代帐公司名称 """ publicPage = PublicPage(self.driver) name_loc = self.driver.find_element_by_xpath(account_company_name_elem) return publicPage.get_value(name_loc)
def get_search_failed_text( self ): """ :return:未查找到详细信息 """ publicPage = PublicPage(self.driver) text_loc = self.driver.find_element_by_xpath(search_failed_elem) text = publicPage.get_value(text_loc) print('text=>', text) return text
def get_comp_num(self): """ :return:返回帐套数量 """ text_loc = self.driver.find_element_by_xpath(comp_num_elem) publicPage = PublicPage(self.driver) text = publicPage.get_value(text_loc) comp_num = re.findall('\d+', text) print('comp_num=', comp_num[0]) return comp_num[0]
def get_comp_name(self): """ :return: 帐套名称 """ try: publicPage = PublicPage(self.driver) comp_name_loc = self.driver.find_element_by_id(comp_name_text_id) print('comp_name') return publicPage.get_value(comp_name_loc) except NoSuchElementException as e: logging.error('查找的页面元素不存在,异常堆栈信息:' + str(traceback.format_exc())) except Exception as e: print('[CompBillingPage] get_comp_name---获取帐套名称失败,失败原因是=>', str(e))
def get_comp_name_list(self): """ :return:获取帐套列表中所有帐套名称,并以list的形式返回。 """ publicPage = PublicPage(self.driver) tr_locs = self.driver.find_element_by_tag_name( 'tbody').find_elements_by_tag_name('tr') names = [] for tr_loc in tr_locs: tr_index = tr_locs.index(tr_loc) if len(tr_locs[tr_index].find_elements_by_tag_name('a')) == 2: name_xpath = 'td[1]/div/div/a[2]' else: name_xpath = 'td[1]/div/div/a' name_loc = tr_locs[tr_index].find_element_by_xpath(name_xpath) name = publicPage.get_value(name_loc) names.append(name) print('comp_name_list=', names) return names
def get_current_accounting_period(self, period_or_statue=None): """ 获取当前会计期间、帐套状态 :period_or_statue : 想要返回的值,可选值(period:会计期间,statue:帐套状态,空:返回两个值 :return:会计期间:2018-08 进行中(accounting_period:当前跨季期间2018-08, """ publicPage = PublicPage(self.driver) text_loc = self.driver.find_element_by_xpath(accounting_period_elem) values = publicPage.get_value(text_loc) value = values.split(' ') accounting_period = value[0].split(':')[1] accounting_statue = value[2] if period_or_statue == 'period': print('accounting_period=', accounting_period) return accounting_period elif period_or_statue == 'statue': print('accounting_statue=', accounting_statue) return accounting_statue else: print('accounting_period=', accounting_period, ',accounting_statue=', accounting_statue) return accounting_period, accounting_statue
def enter_comp(self, comp_name=None): """ :param comp_name: 帐套名称(当帐套名称为空时,默认进入最后一个帐套) :return: 点击帐套名称进入帐套 """ try: publicPage = PublicPage(self.driver) if comp_name is None: tr_locs = self.driver.find_element_by_tag_name( 'tbody').find_elements_by_tag_name('tr') index = int(self.get_comp_num()) - 1 print('index=', index) if len(tr_locs[index].find_elements_by_tag_name('a')) == 2: name_xpath = 'td[1]/div/div/a[2]' else: name_xpath = 'td[1]/div/div/a' name_loc = tr_locs[index].find_element_by_xpath(name_xpath) comp_name = publicPage.get_value(name_loc) print('comp_name=', comp_name) comp_loc = self.driver.find_element_by_link_text(comp_name) publicPage.click_elem(comp_loc) except Exception as e: print('[CompListPage]enter_comp:进入帐套失败,失败原因=>', str(e))