def input_last_storetime(self, lasttime): last_storetime_element = UiUtil.find_elment("sales", "last_time") # 待封装; js = 'document.getElementById("laststoretime").removeAttribute("readonly")' self.driver.execute_script(js) # 待封装; UiUtil.input(last_storetime_element, lasttime)
def input_early_storetime(self, earlytime): early_storetime_element = UiUtil.find_elment("sales", 'early_time') js = 'document.getElementById("earlystoretime").removeAttribute("readonly")' self.driver.execute_script(js) UiUtil.input(early_storetime_element, earlytime)
def do_login_test(self, path, section, option): #根据路径打开的文件含有excel的地址信息,根据这个地址,再去打开excel文件、 contents = FileUtil.get_test_info( path, section, option) #三个参数,分别是含含有excel相关数据的存放地址,section和option值 # print(contents) i = 0 for content in contents: i = i + 1 # 执行登录操作; Login(self.driver).do_login(content) #使用try抛出异常,去定位元素; try: logout_button_element = UiUtil.find_elment( "login", 'logout_button') UiUtil.click(logout_button_element) print(f"第{i}次 登录成功") except: time.sleep(2) print(f"第{i}次 登录失败") self.driver.refresh()
def input_account(self, username): uname = UiUtil.find_elment('login','uname') UiUtil.input(uname, username)
def click_login_button(self): login_button = UiUtil.find_elment('login','login_button') UiUtil.click(login_button)
def input_verifycode(self, verifycode): vfcode = UiUtil.find_elment('login','vfcode') UiUtil.input(vfcode, verifycode)
def input_password(self, password): upass = UiUtil.find_elment('login','upass') UiUtil.input(upass, password)
def input_account(self, username): uname = UiUtil.find_elment('login','uname') UiUtil.input(uname, username) def input_password(self, password): upass = UiUtil.find_elment('login','upass') UiUtil.input(upass, password) def input_verifycode(self, verifycode): vfcode = UiUtil.find_elment('login','vfcode') UiUtil.input(vfcode, verifycode) def click_login_button(self): login_button = UiUtil.find_elment('login','login_button') UiUtil.click(login_button) def do_login(self, login_data): self.input_account(login_data['username']) self.input_password(login_data['password']) self.input_verifycode(login_data['verifycode']) self.click_login_button() #完成登录后需不需要点击注销;如果点击了怎么进行判断页面元素, if __name__ == '__main__': driver = UiUtil.get_driver() login_data = {'username':'******', 'password':'******', 'verifycode':'0000'} Login(driver).do_login(login_data)
def click_search_button(self): search_button_element = UiUtil.find_elment("sales", "search_button") UiUtil.click(search_button_element)
def input_goodstype(self, type): serial_element = UiUtil.find_elment("sales", 'goods_type') #下拉框,只需要输入两个参数即可; UiUtil.select_by_text(serial_element, type)
def input_barcode(self, barcode): barcode_element = UiUtil.find_elment("sales", 'barcode') UiUtil.input(barcode_element, barcode)
def input_goodsname(self, name): goods_name_element = UiUtil.find_elment("sales", "goods_name") UiUtil.input(goods_name_element, name)
def input_goodsserial(self, serial): goods_serial_element = UiUtil.find_elment( "sales", "goods_serial") #等写了框架,把信息写入inspector文件; UiUtil.input(goods_serial_element, serial)
def click_store_page(self): store_page_element = UiUtil.find_elment("sales", "store_page") UiUtil.click(store_page_element)