def submit(self, btn_name): """ :param btn_name: 按钮名,可选值(save_and_new,save,cancel) :return: 保存并新增,保存,取消 """ try: if btn_name == 'save_and_new': btn_elem = save_and_new_btn_elem submit_name = '保存并新增' elif btn_name == 'save': btn_elem = save_btn_elem submit_name = '保存' elif btn_name == 'cancel': btn_elem = cancel_btn_elem submit_name = '取消' publicPage = PublicPage(self.driver) btn_loc = self.driver.find_element_by_xpath( record_invoice_base_xpath + self.invoice_io + btn_elem) publicPage.click_elem(btn_loc) except Exception as e: print('[RecordInvoicePage]--' + submit_name + '失败--失败原因是->', str(e)) self.driver.quit()
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))
def invite_user(self, user_info): """ :param user_info: 用户名{0:会计/助理/客户联系人,1:帐套名称[当等于current_user时,默认分配当前登陆用户],2:用户名,3:手机号} :return: 选择/邀请用户 """ publicPage = PublicPage(self.driver) topBarPage = TopBarPage(self.driver) compListPage = CompListPage(self.driver) compListPage.click_distribute_btn(user_info[0], user_info[1]) names = self.get_name_list() if user_info[2] in names: self.select_name(user_info[2]) elif user_info[2] == 'current_user': current_user = topBarPage.get_login_user_name() self.select_name(current_user) elif user_info[3] not in self.get_phone_list(): drop_loc = self.driver.find_element_by_xpath(name_drop_elem) publicPage.click_elem(drop_loc) name_loc = self.driver.find_element_by_partial_link_text('+新增用户') publicPage.click_elem(name_loc) self.set_name(user_info[0]) self.set_phone(user_info[1]) self.submit('save')
def go_to_setting_page(self, page_name): publicPage = PublicPage(self.driver) link_loc = self.driver.find_element_by_link_text(page_name) publicPage.click_elem(link_loc)
def click_user_name(self): click_loc = self.driver.find_element_by_xpath(user_setting_elem) publicPage = PublicPage(self.driver) publicPage.click_elem(click_loc)
def setUpClass( self ): # def setUp(self): # self.driver = webdriver.PhantomJS() self.driver = webdriver.Chrome() PublicPage(self.driver).max_window() self.driver.implicitly_wait(30)
def setUpClass(self): self.driver = webdriver.Chrome() self.driver.implicitly_wait(30) PublicPage(self.driver).max_window()
def has_danger_is_show(self): publicPage = PublicPage(self.driver) ui_loc = self.driver.find_element_by_css_selector(has_danger_elem) print('publicPage.is_element_present(ui_loc)=>', publicPage.is_element_present(ui_loc)) return publicPage.is_element_present(ui_loc)
def upload_file(self): publicPage = PublicPage(self.driver) upload_btn_loc = self.driver.find_element_by_id('fileUploadBtn') publicPage.is_element_present(upload_btn_loc) upload_btn_loc.send_keys(self.file_dir)