def setup_class(cls):
     cls.screenshots_folder = BaseUtil().root_path + "/screenshots/东印"
     make_folder(cls.screenshots_folder)
     current_time = BaseUtil().get_current_time()
     cls.result_images = cls.screenshots_folder + "/" + current_time
     make_folder(cls.result_images)
     base_driver = BaseDriver()
     cls.driver = base_driver.applet_driver()
     # 打开微信
     cls.ele_page = PageDongYin(cls.driver)
     cls.ele_page.click(cls.ele_page.discovery)
     cls.ele_page.swipe_up()
     # 打开小程序
     cls.ele_page.click(cls.ele_page.applet)
     cls.ele_page.sleep(3)
     cls.ele_page.tap(int(995 / 1080 * cls.ele_page.width),
                      int(145 / 1920 * cls.ele_page.height))
     # 搜索小程序
     cls.ele_page.click(cls.ele_page.search_applet)
     cls.ele_page.send_keys(cls.ele_page.search_applet, "东印")
     cls.ele_page.sleep(3)
     cls.ele_page.tap(int(540 / 1080 * cls.ele_page.width),
                      int(286 / 1920 * cls.ele_page.height))
     cls.ele_page.sleep(3)
     cls.ele_page.tap(int(540 / 1080 * cls.ele_page.width),
                      int(286 / 1920 * cls.ele_page.height))
     cls.ele_page.sleep(8)
Exemple #2
0
 def __init__(self):
     self.platformName = BaseUtil().get_yaml_value("DEVICES",
                                                   "platformName")
     self.platformVersion = BaseUtil().get_yaml_value(
         "DEVICES", "platformVersion")
     self.deviceName = BaseUtil().get_yaml_value("DEVICES", "deviceName")
     self.browserName = BaseUtil().get_yaml_value("DEVICES", "browserName")
     self.app = BaseUtil().get_yaml_value("DEVICES", "app")
     self.appPackage = BaseUtil().get_yaml_value("DEVICES", "appPackage")
     self.appActivity = BaseUtil().get_yaml_value("DEVICES", "appActivity")
     self.automationName = BaseUtil().get_yaml_value(
         "DEVICES", "automationName")
     self.unicodeKeyboard = BaseUtil().get_yaml_value(
         "DEVICES", "unicodeKeyboard")
     self.resetKeyboard = BaseUtil().get_yaml_value("DEVICES",
                                                    "resetKeyboard")
     self.newCommandTimeout = BaseUtil().get_yaml_value(
         "DEVICES", "newCommandTimeout")
     self.noReset = BaseUtil().get_yaml_value("DEVICES", "noReset")
     self.chromeOptions = BaseUtil().get_yaml_value("DEVICES",
                                                    "chromeOptions")
Exemple #3
0
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @author: sharly

import pymysql
from utils.baseutil import BaseUtil
from utils.logger import Logger

logger = Logger(logger="MysqlDB").get_log()
db_host = BaseUtil().get_config_value("MySql", "host")
port = BaseUtil().get_config_value("MySql", "port")
username = BaseUtil().get_config_value("MySql", "username")
password = BaseUtil().get_config_value("MySql", "password")
db_name = BaseUtil().get_config_value("MySql", "db_name")
charset = BaseUtil().get_config_value("MySql", "charset")


class MySql(object):
    def __init__(self):
        try:
            self.connection = pymysql.connect(host=db_host,
                                              port=int(port),
                                              user=username,
                                              password=password,
                                              database=db_name,
                                              charset=charset)
        except pymysql.err.OperationalError as e:
            logger.info("Mysql Error %d: %s" % (e.args[0], e.args[1]))

    def create_db(self, sql_query):
        con = self.connection
Exemple #4
0
import pytest
import time

curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = os.path.split(curPath)[0]
sys.path.append(rootPath)
from utils.baseutil import BaseUtil
from utils.shell import Shell
from utils.logger import Logger

logger = Logger(logger="run").get_log()

if __name__ == '__main__':
    # # 打开appium
    # Shell.invoke("appium -a 127.0.0.1 -p 4723")
    # time.sleep(5)
    # 获取report的路径
    xml_report_path = BaseUtil().get_yaml_value("EnvironmentInfo", "xml_report")
    html_report_path = BaseUtil().get_yaml_value("EnvironmentInfo", "html_report")
    # 开始执行测试
    args = ['-s', '-q', '--alluredir', xml_report_path]
    self_args = sys.argv[1:]
    pytest.main(args + self_args)
    # 生成html测试报告
    cmd = 'allure generate %s -o %s  --clean' % (xml_report_path, html_report_path)
    try:
        Shell.invoke(cmd)
        logger.info("Html测试报告生成成功")
    except Exception as e:
        logger.error("Html测试报告生成失败,确保已经安装了Allure-Commandline % s" % e)
Exemple #5
0
    if os.path.exists(folder_path):
        shutil.rmtree(folder_path)
        logger.info("The Folder %s had been deleted" % folder_path)
    else:
        logger.info("Folder %s is not exist" % folder_path)


def make_folder(folder_path):
    """create folder"""
    if os.path.exists(folder_path):
        logger.info("Folder %s is exist" % folder_path)
    else:
        os.mkdir(folder_path)
        logger.info("Folder %s is created" % folder_path)


def copy_folder(olddir_path, newdir_path):
    """copy folder,olddir and newdir must be folder type"""
    delete_folder(newdir_path)
    if os.path.exists(newdir_path):
        shutil.rmtree(newdir_path)
    shutil.copytree(olddir_path, newdir_path)


if __name__ == '__main__':
    screenshots_folder = BaseUtil().root_path + "/screenshots/恭和家园"
    make_folder(screenshots_folder)
    current_time = BaseUtil().get_current_time()
    result_images = screenshots_folder + "/" + current_time
    make_folder(result_images)
Exemple #6
0
import sys
import pytest
import time

curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = os.path.split(curPath)[0]
sys.path.append(rootPath)
from utils.baseutil import BaseUtil
from utils.shell import Shell
from utils.logger import Logger
from utils.appiumserver import AppiumServer

logger = Logger(logger="run").get_log()

if __name__ == '__main__':
    cur_time = BaseUtil().get_current_time()
    s = AppiumServer()
    s.start_appium('127.0.0.1', 4723, "CLB0219116000104", BaseUtil().root_path + "/logs/appium-" + cur_time + ".log")
    time.sleep(8)
    # 获取report的路径
    xml_report_path = BaseUtil().get_yaml_value("EnvironmentInfo", "xml_report")
    html_report_path = BaseUtil().get_yaml_value("EnvironmentInfo", "html_report")
    # 开始执行测试
    args = ['-s', '-q', '--alluredir', xml_report_path]
    self_args = sys.argv[1:]
    pytest.main(args + self_args)
    # 生成html测试报告
    cmd = 'allure generate %s -o %s --clean' % (xml_report_path, html_report_path)
    try:
        Shell.invoke(cmd)
        logger.info("Html测试报告生成成功")