Exemplo n.º 1
0
 def __init__(self, ):
     browser = readConfig('config.ini', 'browser', 'browser')
     self.driver = init_env().open_browser(browser)
     # self.basePageAction = BasePage(driver)
     # 每步执行结果
     self.stepResult = {}
     # 测试集合执行结果
     self.caseResult = {}
Exemplo n.º 2
0
def loginJira():
    server = readConfig('config.ini', 'server', 'server')
    user_name = readConfig('config.ini', 'user', 'user_name')
    password = readConfig('config.ini', 'user', 'password')
    conf = (user_name, password)
    try:
        login = JIRA(server=server, basic_auth=conf)
    except Exception as e:
        if isinstance(e, JIRAError):
            _mylogger.error(u'登录失败 %s' % e.text)
            result = e.text
        else:
            _mylogger.error(u'登录失败 %s' % e)
            result = e

        return result
    else:
        _mylogger.info(u'登录成功')
        return login
Exemplo n.º 3
0
    def chose_product(self, selector=None, text=None):
        value = readConfig('constant', 'const', 'PRODUCT')
        try:
            _mylogger.info(u'选择产品')
            element = self.find_element(selector)
            element.click()
            time.sleep(0.5)
            element.find_element_by_xpath(value).click()

        except Exception as e:
            _mylogger.error('发生异常:{}'.format(e))
Exemplo n.º 4
0
    def chose_customerName(self, selector=None, text=None):
        value = readConfig('constant', 'const', 'CUSTOMERNAME')
        try:
            _mylogger.info(u'选择客户名称')
            element = self.find_element(selector)
            element.click()
            time.sleep(0.5)
            element.find_element_by_xpath(value).click()

        except Exception as e:
            _mylogger.error('发生异常:{}'.format(e))
Exemplo n.º 5
0
 def chose_fundManager(self, selector=None, text=None):
     value = readConfig('constant', 'const', 'FUNDMANAGER')
     try:
         _mylogger.info(u'选择基金经理')
         element = self.find_element(selector)
         element.click()
         time.sleep(0.5)
         element.find_element_by_xpath(value).click()
         # 向上滚动
         self.driver.execute_script("window.scrollTo(0,0)")
     except Exception as e:
         _mylogger.error('发生异常:{}'.format(e))
Exemplo n.º 6
0
def customer_config():
    log_file = os.path.join(readConfig('config.ini', 'log', 'log_file'),
                            'log.log')
    print log_file
    logging.root.setLevel(logging.DEBUG)
    # 控制台、日志文件输出日志格式设置
    format1 = logging.Formatter(
        '[%(asctime)s] [%(name)s] [%(levelname)s] %(lineno)s %(message)s')
    format2 = logging.Formatter(
        '[%(name)s] [%(levelname)s] %(lineno)s %(message)s')
    # 创建控制台输出日志的handler
    ch = logging.StreamHandler()
    ch.setLevel(logging.DEBUG)
    ch.setFormatter(format2)
    # 创建文件输出日志的handler
    fh = RotatingFileHandler(log_file,
                             maxBytes=10 * 1024 * 1024,
                             backupCount=10)  # 日志文件最大10M,最多备份5个文件
    fh.setLevel(logging.INFO)
    fh.setFormatter(format1)
    # 为logging添加handler
    logging.root.addHandler(ch)
    logging.root.addHandler(fh)
Exemplo n.º 7
0
# coding=utf-8
import os
import smtplib
from email.header import Header
from email.mime.multipart import MIMEMultipart

from email.mime.text import MIMEText

from lib.log_config import get_logger
from lib.read_config import readConfig
_mylogger = get_logger('bamboo')

mailto_list = readConfig('config.ini', 'email',
                         'mailto_list').replace(' ', '').split(',')  # 收件人列表
mail_host = readConfig('config.ini', 'email', 'mail_host')  # 配置邮件服务器
mail_from = readConfig('config.ini', 'email', 'mail_from')  #发件人
mail_pass = readConfig('config.ini', 'email', 'mail_pass')  #密码
mail_postfix = readConfig('config.ini', 'email', 'mail_postfix')  # 密码


def send_mail(sub, content, reportFile):  # to_list:收件人;sub:主题;content:邮件内容
    msg = MIMEText(_text=content, _charset='utf-8')  #创建一个实例,这里设置为html格式邮件
    msg['Subject'] = sub  #设置主题

    msg = MIMEMultipart()
    msg.attach(MIMEText(content, 'plain', 'utf-8'))
    part = MIMEText(open(reportFile, 'rb').read(), 'base64', 'utf-8')
    part["Content-Type"] = 'application/octet-stream'
    part["Content-Disposition"] = 'attachment; filename="%s"' % reportFile
    msg.attach(part)  #添加附件