示例#1
0
    def __init__(self, dbsetion=None):
        if dbsetion == None:
            self.dbsetion = 'sit-database'
        else:
            self.dbsetion = dbsetion

        self.cfg = getConfig()

        db_name = self.cfg.get_config(self.dbsetion, 'db_name')
        user = self.cfg.get_config(self.dbsetion, 'user')
        password = self.cfg.get_config(self.dbsetion, 'password')
        host = self.cfg.get_config(self.dbsetion, 'host')
        port = self.cfg.get_config(self.dbsetion, 'port')

        self.conn = psycopg2.connect(database=db_name,
                                     user=user,
                                     password=password,
                                     host=host,
                                     port=port)
        self.cur = self.conn.cursor()
示例#2
0
    def get_element(self,setion,option,filename=None):
        element = None
        cfg = getConfig(filename)
        data = cfg.getconfig(setion,option)
        by = data.split(">")[0]
        locater = data.split(">")[1]
        print(by,locater)
        try:
            locate = (By.XPATH, locater)
            re = WebDriverWait(self.driver, 5).until(EC.visibility_of_element_located(locate))

            if by == 'xpath':
                element = self.driver.find_element_by_xpath(locater)

            elif by == 'id':
                element = self.driver.find_element_by_id(locater)
            else:
                element = self.driver.find_element_by_xpath(locater)
        except:
            print("定位方式错误")

        return element
示例#3
0
 def setUp(self):
     cfg = getConfig()
     self.driver = webdriver.Chrome()
     self.driver.get(getConfig().getconfig('url', 'login_url'))
     self.log_bus = loginBusiness(self.driver)
示例#4
0
import os
import sys
curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = os.path.split(curPath)[0]
sys.path.append(rootPath)

import unittest
from utils.operate_excel import operateExcel
from data.get_data import getData
import utils.Log
import base.HTMLTestRunner as HTMLTestRunner
from utils.send_email import sendEmail
from utils.get_config import getConfig

log = utils.Log.logger
on_off = getConfig().get_config("email", "on_off")
usr_list = getConfig().get_config("email", "recv_usr_list")
sub = getConfig().get_config("email", "sub")
content = getConfig().get_config("email", "content")


class AllTest:
    def __init__(self):
        global resultPath
        resutldir = os.path.dirname(os.getcwd())
        resultPath = os.path.join(resutldir, 'testReport', "report.html")
        self.caseListFile = os.path.join(resutldir, 'testcase', "caselist.txt")
        self.caseFile = os.path.join(resutldir, 'testcase')
        self.caseList = []
        log.info('resultPath=%s', resultPath)
示例#5
0
 def __init__(self):
     self.cfg = getConfig()
示例#6
0
        msg['Subject'] = sub  # 邮件主题
        msg['From'] = user  # 发送者账号
        msg['To'] = usr_list  # 接收者账号列表
        log.info("usr_list = %s", usr_list)
        log.info("msg['To']  = %s", msg['To'])
        email_host = self.cfg.get_config("email", "email_host")
        log.info("email_host = %s", email_host)
        server = smtplib.SMTP()
        server.connect(email_host)
        # 发送邮件服务器的对象
        password = self.cfg.get_config("email", "password")
        server.login(user, password)
        try:
            server.sendmail(user, str(usr_list).split(","), msg.as_string())
            pass
        except Exception as e:
            log.info('出错了。。', e)
        else:
            log.info('邮件发送成功!')
        server.close()


if __name__ == '__main__':
    send = sendEmail()
    cfg = getConfig()
    usr_list = cfg.get_config("email", "recv_usr_list")
    sub = cfg.get_config("email", "sub")
    context = "接口测试报告"
    #send.send_email(usr_list, sub, context)
    send.send_email2(usr_list, sub, context)