def testLog012(self): '''验证快速创建日志,明天工作内容输入1001个字母,提示是否正确''' Mylogin(self.driver).login() Mylogin(self.driver).mklog() url1 = self.driver.current_url self.driver.find_element_by_xpath("//div[@class='form']/div[2]/div/textarea").send_keys(mkstr.letters(1001))#输入1001个字母 self.driver.find_element_by_xpath("//div[@class='el-card__body']/div/div/button[1]/span").click() makeText = self.driver.find_element_by_xpath("/html/body/div[5]/p") time.sleep(3) url2 = self.driver.current_url self.assertEqual(makeText.text, "新建失败")#验证提示信息 self.assertEqual(url1, url2) #验证返回界面
def testLog011(self): '''验证明天工作内容框输入1000字符,提示是否正确,返回日志页面''' Mylogin(self.driver).login() Mylogin(self.driver).mklog() self.driver.find_element_by_xpath("//div[@class='form']/div[2]/div/textarea").send_keys(mkstr.letters(1000))#输入1000字符 self.driver.find_element_by_xpath("//div[@class='el-card__body']/div/div/button[1]/span").click() WebDriverWait(self.driver, 10, 0.5).until( EC.presence_of_element_located((By.XPATH, '//*[@id="app"]/section/section/aside/div/ul/a[5]/li/span')))#定位日志页面 try: self.driver.implicitly_wait(5) makeText = self.driver.find_element_by_xpath("//div[@role='alert']/p") self.assertEqual(makeText.text,'新建成功') print("提示:新建成功") except: pass journal = self.driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/a[5]/li') journalText = self.driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/a[5]/li/span') allof = self.driver.find_element_by_xpath('//div[@id="tab-1"]') allofText = self.driver.find_element_by_xpath('//div[@id="tab-1"]/div/span') self.assertEqual(journalText.text, '日志') #验证返回日志界面 self.assertIn('menu-item-select',journal.get_attribute('class')) self.assertEqual(allofText.text, '全部') #验证返回全部页面 self.assertEqual('true',allof.get_attribute('aria-selected'))