Exemple #1
0
 def readYaml(self):
     try:
         f = open(self.path, encoding='utf-8')
         data = yaml.load(f)
         f.close()
         return data
     except Exception:
         log.error('未找到yaml文件')
Exemple #2
0
 def get_ids(self, id):
     try:
         elements = WebDriverWait(self.driver, 10).until(lambda x: x.find_elements_by_id(id))
         self.driver.implicitly_wait(2)
         return elements
     except:
         log.error('未定位到元素:'+'%s'%(id))
         self.screenshot()
Exemple #3
0
 def test_1launchvisit(self):
     common.get_name('高级拜访').click()
     try:
         self.assertTrue(common.find_name(u'临时拜访'))
     except Exception, e:
         print e
         log.error('进入高级拜访模块失败')
         common.screenshot("launchvisit.png")
Exemple #4
0
 def get_xpath(self, xpath):
     try:
         element = WebDriverWait(self.driver, 10).until(lambda x: x.find_element_by_xpath(xpath))
         self.driver.implicitly_wait(2)
         return element
     except:
         log.error('未定位到元素:'+'%s'%(xpath))
         self.screenshot()
Exemple #5
0
 def get_toast(self, toast):
     try:
         message = '//*[contains(@text,\'{}\')]'.format(toast)
         element = WebDriverWait(self.driver, 5, 0.5).until(
             EC.presence_of_element_located((By.XPATH, message)))
         log.info('查找到toast:'+'%s'%(element.text))
     except:
         log.error('未查找到toast:'+'%s'%(toast))
Exemple #6
0
 def get_name(self, name):
     findname = "//*[@text='%s']"%(name)
     try:
         element = WebDriverWait(self.driver, 10).until(lambda x: x.find_element_by_xpath(findname))
         self.driver.implicitly_wait(2)
         return element
     except:
         log.error('未定位到元素:'+'%s'%(name))
         self.screenshot()
Exemple #7
0
def send_email():

    mail = get_mail()
    message = MIMEText(mail, 'html', 'utf-8')
    message['From'] = Header("爱学习的圈圈", 'utf-8')
    # message['To'] = Header("圈圈", 'utf-8')
    message['Subject'] = Header('UI自动化测试报告', 'utf-8')

    try:
        server = smtplib.SMTP_SSL("smtp.qq.com", 465)  # 发件人第三方SMTP服务器,端口是465
        server.login(mail_user, mail_pass)
        server.sendmail(sender, receiver, message.as_string())
        server.quit()
        log.info('邮件发送成功')
        # print("邮件发送成功")
    except smtplib.SMTPException:
        log.error('邮件发送失败')
Exemple #8
0
log = log()

<<<<<<< HEAD
driver.find_element_by_id("com.waka:id/edt_login_email").send_keys("*****@*****.**")
=======
driver.find_element_by_id("com.waka:id/edt_login_email").send_keys("*****@*****.**")
>>>>>>> waka
driver.find_element_by_id("com.waka:id/edt_login_password").send_keys("123")
driver.find_element_by_id("com.waka:id/btn_login").click()



def get_Toast(message):
    try:
        mes = '//*[contains(@text,\'{}\')]'.format(message)
        element = WebDriverWait(driver, 5, 0.5).until(
            EC.presence_of_element_located((By.XPATH, mes)))
<<<<<<< HEAD
        log.info('查找到tost:'+'%s'%(message))
    except:
        log.error('没有查找到toast:'+'%s'%(message))

get_Toast(u'该邮箱未注册')
=======
        log.info('查找到toast:'+'%s'%(element.text))
    except:
        log.error('没有查找到toast:'+'%s'%(message))

get_Toast(u'密码错误')
>>>>>>> waka