def setUp(self): self.start = datetime.datetime.now() self.startTime = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime()).split(" ")[-1] MemcacheTools.setMemTime(self.testCaseID,{'start':self.startTime}) lg = LoginTools() self.driver = lg.InitialChrome(self.url, self.testCaseID) self.driver = lg.login(self.driver)
def setUp(self): self.start = datetime.datetime.now() self.startTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()).split(" ")[-1] lg = LoginTools() self.driver = lg.InitialChrome(self.url, self.testCaseID) self.driver = lg.login(self.driver, 'tester1')
def Test(self): for x in range(0, num): lg = LoginTools() self.driver = lg.InitialChrome(url, self.testCaseID) self.driver = lg.login_test(self.driver, user[x], pwd[x]) time.sleep(1) self.driver.quit()
def Test(self): accounts = OldTools.accounts_list("C:\\useraccount\\worklist.xlsx") for key in sorted(accounts.keys()): temp = accounts.get(key) for k in sorted(temp.keys()): lg = LoginTools() driver = lg.loginInitial_Chrome(self.testCaseID) #(driver,time_consumption[1]) x = OldTools.account_audit2(driver, k, temp.get(k)) driver = x[0] print('用户:' + k + '登陆,消耗: %f' % x[1]) time.sleep(1.2) # dropdown list location try: delta = driver.find_element_by_css_selector('#iconList') except Exception: assert 0, '找不到用户菜单按钮' if delta is not None: delta.click() time.sleep(2) try: logout = driver.find_element_by_id('btnLogout') logout.click() wait = WebDriverWait( driver, 30).until(lambda dr: dr.find_element_by_css_selector( '#divLanguage>a')) if wait: pass else: assert 0, '注销失败' except Exception: assert 0, '用户注销失败' driver.quit()
def setUp(self): self.start = datetime.datetime.now() self.startTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()).split(" ")[-1] MemcacheTools.setMemTime(self.testCaseID, {'start': self.startTime}) lg = LoginTools() # OtherTools.setBrowser(lg, self.browserName) self.driver = lg.loginInitial_Chrome(self.testCaseID) self.driver = lg.loginnow(self.driver)
def setUp(self): self.start = datetime.datetime.now() self.startTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()).split(" ")[-1] self.prePoint = time.strftime("Point%Y%m%d%H%M%S", time.localtime()) MemcacheTools.setMemTime(self.testCaseID, {"startTime": self.startTime}) lg = LoginTools() self.driver = lg.InitialChrome(self.url, self.testCaseID) self.driver = lg.login(self.driver) self.tools = WebDriverTools()
def loginBeop(self, driver): lg = LoginTools() self.driver = lg.login(driver, 'tester2') driver2 = self.driver b = WebDriverTools() if b.isElementPresent(driver2, '#iconList'): if driver2.find_element_by_id("iconList"): #driver2.get_screenshot_as_file(r'.\ErrorPicture\%s\%s.png' % (self.testCaseID,time.strftime("%Y-%m-%d %H-%M-%S", time.localtime()))) print("找回密码成功!") else: assert 0, '点击忘记密码后重新设置密码后登陆失败!'
def test(self): lg = LoginTools() self.driver = lg.InitialChrome(self.url, self.testCaseID) self.driver = lg.login(self.driver) self.tools = WebDriverTools() driver = self.driver self.errors = [] self.tools.enterProject(driver, self.project[0], self.project[1], self.errors) sleep(3) self.checkOverview(driver) OtherTools.raiseError(self.errors)
def setUp(self): self.start = datetime.datetime.now() self.startDT = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime()) self.startDate = self.startDT.split(" ")[0] self.startTime = self.startDT.split(" ")[1] MemcacheTools.setMemTime(self.testCaseID,{"startTime":self.startTime}) lg = LoginTools() self.driver = lg.InitialChrome(self.url,self.testCaseID) self.driver = lg.login(self.driver) self.email1 = '*****@*****.**' self.email2 = '*****@*****.**' self.email3 = '*****@*****.**' self.password = '******' self.pop3Server = 'pop3.mxhichina.com' self.mailCount1 = 0 self.mailCount2 = 0 self.mailCount3 = 0
def CheckEmail(self): dr = webdriver.Chrome() dr.get("http://mail.qq.com") dr.maximize_window() #点击切换到账号密码登陆 time.sleep(5) dr.switch_to_frame("login_frame") dr.find_element_by_id("switcher_plogin").click() time.sleep(5) dr.implicitly_wait(8) ele = dr.find_elements_by_class_name("inputOuter") time.sleep(5) dr.find_element_by_css_selector("#uinArea>div>input").send_keys( "*****@*****.**") dr.find_element_by_css_selector("#pwdArea>div input").send_keys( "woody312") dr.find_element_by_id("login_button").click() time.sleep(2) x = WebDriverTools() while 1: if x.isElementPresent(dr, '#useraddr'): dr.switch_to_frame("mainFrame") break else: dr.find_element_by_id("login_button").click() time.sleep(4) WebDriverWait(dr, 15).until(lambda x: x.find_element_by_css_selector( "li[class='mailinfo1 t_left2'] >div>a")) time.sleep(5) dr.find_element_by_css_selector( "li[class='mailinfo1 t_left2'] >div>a").click() WebDriverWait(dr, 15).until( lambda x: x.find_elements_by_css_selector(".toarea table")) #进入第一封邮件 dr.find_elements_by_css_selector(".toarea table")[0].click() time.sleep(3) url = '' eles = dr.find_elements_by_css_selector(".contentEditable a") for ele in eles: if ele.text is not None and "http://beop" in ele.text: print("find register url!") url = ele.text '''pat = re.compile("http://(.+)\\n$") x2 = re.search(pat,text) x2 = re.split("账户",text) urls = x2[-1].split('\n') url = urls[1] if "beop" in url: print(url) else: dr.get_screenshot_as_file(r'.\ErrorPicture\%s\%s.png' % (self.testCaseID,time.strftime("%Y-%m-%d %H-%M-%S", time.localtime()))) assert 0,"邀请注册的url地址不正确!" ''' time.sleep(5) dr.get(url) time.sleep(7) try: WebDriverWait( dr, 8).until(lambda x: x.find_element_by_id("inputPassword1")) except Exception as e: print(e) dr.get_screenshot_as_file( r'.\ErrorPicture\%s\%s.png' % (self.testCaseID, time.strftime("%Y-%m-%d %H-%M-%S", time.localtime()))) assert 0, "邀请用户注册->用户打开邮件后未进入到注册页面,因为页面中没有找到密码输入框!(等待10秒)" dr.close() dr.find_element_by_id("inputPassword1").send_keys("rnbtech1103") dr.find_element_by_id("inputPassword2").send_keys("rnbtech1103") dr.find_element_by_id("submitBtn").click() time.sleep(20) try: if dr.find_element_by_id("submitBtn"): assert 0, "邀请用户注册页面->点击提交按钮进行注册的时候,一直显示正在注册中!" except Exception: pass # assert 0,"邀请用户注册页面->点击提交按钮进行注册的时候,一直显示正在注册中!" if x.isElementPresent(dr, '#txtName'): print('登录页存在!') dr.find_element_by_id("txtName").clear() dr.find_element_by_id("txtName").send_keys("*****@*****.**") dr.find_element_by_id("txtPwd").clear() dr.find_element_by_id("txtPwd").send_keys("rnbtech1103") dr.find_element_by_id("btnLogin").click() a2 = WebDriverTools() #cur_time = time.time() self.find_alert(dr) #a2.find_spinner(dr, cur_time, project='新注册用户登陆页面', timeout='23',name='spinner') WebDriverWait(dr, 20).until(lambda x: x.find_element_by_id("iconList")) time.sleep(5) try: dr.find_element_by_css_selector('#iconList').click() user = dr.find_element_by_id('paneUser') except Exception: assert 0, '登录用户名显示失败' name = user.text namenow = "Woody" if name == namenow: pass else: dr.get_screenshot_as_file( r'.\ErrorPicture\%s\%s.png' % (self.testCaseID, time.strftime("%Y-%m-%d %H-%M-%S", time.localtime()))) assert 0, '登录用户与显示的用户不一致' time.sleep(5) dr.quit() dr = webdriver.Chrome() dr.implicitly_wait(8) dr.get(self.url) time.sleep(10) dr.maximize_window() time.sleep(5) lg = LoginTools() dr = lg.login(dr) WebDriverWait(dr, 20).until(lambda x: x.find_element_by_id("iconList")) time.sleep(5) #点击用户菜单 dr.find_element_by_id("iconList").click() #进入员工管理界面 dr.find_element_by_id("btnMemberManage").click() WebDriverWait( dr, 5).until(lambda x: x.find_element_by_class_name("addPersonTxt")) '''names = dr.find_elements_by_css_selector(".userfullname") for name in names: if name.text == "Woody": name.find_element_by_xpath("../../dt[@class='setting']").click()''' dr.find_elements_by_css_selector('.setting')[-1].click() time.sleep(4) dr.find_element_by_id("userDel").click() time.sleep(1) dr.find_element_by_id("deleteUser").click() dr.quit()