def test_send_mail4(self): '''只填写收件人、主题、正文发送邮件''' self.log.info("-------发送邮件成功用例:start!-----------") driver = self.driver driver.get(self.url) # 登录 login(self, "dsfsun", "19900506asd") # 写信 driver.find_element_by_css_selector("#_mail_component_70_70").click() # 填写收件人 driver.find_element_by_xpath(".//*[@class='bz0']/div[2]/div/input" ).send_keys("*****@*****.**") # 填写主题 driver.find_element_by_xpath( "//input[@class='nui-ipt-input' and @type='text' and @maxlength='256']" ).send_keys("给邓诗芳的信") # 填写正文 class_name = driver.find_element_by_class_name("APP-editor-iframe") driver.switch_to.frame(class_name) driver.find_element_by_tag_name("body").send_keys("好久不见") # 发送 driver.switch_to.default_content() driver.find_element_by_xpath( "/html/body/div[2]/div/div[2]/header/div/div/div/span[2]").click() # 断言验证发送成功的提示 text = driver.find_element_by_class_name("tK1").text self.assertIn("发送成功", text) self.log.info("-------发送邮件成功用例:end!-----------")
def test_send_mail3(self): '''填写收件人和主题发送邮件''' self.log.info("-------发送邮件成功用例:start!-----------") driver = self.driver driver.get(self.url) # 登录 login(self, "dsfsun", "19900506asd") # 写信 driver.find_element_by_css_selector("#_mail_component_70_70").click() # 填写收件人 driver.find_element_by_xpath(".//*[@class='bz0']/div[2]/div/input" ).send_keys("*****@*****.**") # 填写主题 driver.find_element_by_xpath( "//input[@class='nui-ipt-input' and @type='text' and @maxlength='256']" ).send_keys("给邓诗芳的信") # 添加附件 driver.find_element_by_class_name("O0").send_keys( "D:\\testSelenium\\test.txt") # 发送 driver.find_element_by_xpath( "/html/body/div[2]/div/div[2]/header/div/div/div/span[2]").click() # 断言验证发送成功的提示 text = driver.find_element_by_class_name("tK1").text self.assertIn("发送成功", text) self.log.info("-------发送邮件成功用例:end!-----------")
def test_user_null(self): '''用户名为空,只输入密码''' self.log.info("------登录失败用例:start!---------") driver = self.driver user_pwd_msg = self.user_pwd_msg driver.get(self.url) username = user_pwd_msg[2][0] self.log.info("不输入用户名:%s" % username) password = user_pwd_msg[2][1] self.log.info("输入正确的密码:%s" % password) msg = user_pwd_msg[2][2] login(self, username, password) driver.switch_to.frame("x-URS-iframe") text = driver.find_element_by_xpath(".//*[@id='nerror']").text self.log.info("获取测试结果:%s" % text) self.assertEqual(text, msg) self.log.info("-------登录失败用例:end!-----------")
def test_search_mail(self): '''搜索邮件''' self.log.info("-------搜索邮件成功用例:start-----------") driver = self.driver driver.get(self.url) login(self, "dsfsun", "19900506asd") # 输入搜索关键字 driver.find_element_by_xpath( "//input[@class='nui-ipt-input' and @type='text']").send_keys( "邓诗芳") # 完成搜索动作 driver.find_element_by_xpath( "//input[@class='nui-ipt-input' and @type='text']").send_keys( Keys.ENTER) # 断言验证结果 text = driver.find_element_by_xpath("//div[@class='tb0']/div/h1").text # text = driver.find_element_by_xpath("//div[@id='dvMultiTab']/u1/li[7]/div[3]").text self.assertEqual(text, "搜索结果") self.log.info("-------搜索邮件成功用例:end!-----------")
def test_send_mail1(self): '''只填写收件人发送邮件''' self.log.info("-------发送邮件成功用例:start!-----------") driver = self.driver driver.get(self.url) # 登录 login(self, "dsfsun", "19900506asd") # 写信 driver.find_element_by_css_selector("#_mail_component_70_70").click() # 填写收件人 driver.find_element_by_xpath(".//*[@class='bz0']/div[2]/div/input" ).send_keys("*****@*****.**") # 发送 driver.find_element_by_xpath( "/html/body/div[2]/div/div[2]/header/div/div/div/span[2]").click() # 确认 driver.find_element_by_xpath( "//*[@class='nui-msgbox-ft-btns']/div/span").click() # 断言验证发送成功的提示 text = driver.find_element_by_class_name("tK1").text self.assertIn(text, "发送成功") self.log.info("-------发送邮件成功用例:end!-----------")
def test_del_mail(self): '''删除邮件''' self.log.info("-------删除邮件成功用例:start!-----------") driver = self.driver driver.get(self.url) login(self,"dsfsun","19900506asd") # 查看收件箱 driver.find_element_by_id("_mail_component_78_78").click() time.sleep(3) driver.find_elements_by_xpath("//span[@class='nui-chk-symbol']/b").pop(1).click() try: spans = driver.find_elements_by_class_name("nui-btn-text") for s in spans: if s.text == "删 除": s.click() except: pass # 断言判断是否已被删除 # text = driver.find_element_by_css_selector("span.nui-tips-text>a").text # self.assertEqual(text,"已删除") self.log.info("-------删除邮件成功用例:end!-----------")