Beispiel #1
0
def MyDriver(cmdopt):
    # 初始化日志
    log = Log()
    log.set_logger(cmdopt, setLevel='info')

    # 初始化设备
    basepage = BasePage()
    basepage.set_driver(cmdopt)
    basepage.set_openfastinput_ime()

    # 获取apk名启动
    rc = ReadConfig()
    driver = basepage.d.session(rc.get_apk_name())

    return_dict = {'basepage': basepage, 'driver': driver, 'log': log}
    yield return_dict
    print("driver finished")
    basepage.set_original_ime()
    driver.close()
# @Author :Zhang Jing
# @Date   :2020/5/14 11:32
# @Desc   :
import time
import unittest
import HTMLTestRunner
import ddt

from Base.BaseDB import MonitorDB
from Base.BaseLog import Log
from Base.BaseSettings import TEST_DATA_YAML
from PageObject.index.IndexRegister import Register

filepath = TEST_DATA_YAML + "\\index\\register.yaml"
sqlfilepath = TEST_DATA_YAML + "\\index\\test.sql"
log = Log()


@ddt.ddt
class TestIndexRegister(unittest.TestCase):
    def setUp(self) -> None:
        self.register = Register()

    def tearDown(self) -> None:
        self.register.quit()

    @classmethod
    def setUpClass(cls) -> None:
        db = MonitorDB()
        db.sql_execute_file(sqlfilepath)
Beispiel #3
0
# !/usr/bin/python3.7
# -*- coding: UTF-8 -*-
# author: lucien
# package: uiautomator2

import uiautomator2 as u2
import time
import os
import subprocess
from uiautomator2 import UiObjectNotFoundError
from Base.BaseLog import Log
from Base.BaseReadConfig import ReadConfig

PATH = lambda p: os.path.abspath(os.path.join(os.path.dirname(__file__), p))
log = Log()
rc = ReadConfig()


class BasePage(object):
    @classmethod
    def set_driver(cls, adder):
        '''
        :param adder: 既可以为设备uuid,也可以填写同一网段设备的ip地址
        '''
        cls.d = u2.connect(adder)

    def get_driver(self):
        return self.d

    # 截图
    def screenshot_ll(self, report_path):
Beispiel #4
0
"""
@Author: Lidi
@Time  : 2019/6/23 20:24
@Desc  : Run all case
"""
from HTMLTestRunner import HTMLTestRunner
from Base.BaseRunner import ParametrizedTestCase
from Base.BaseAdb import AdbOperate
from Base.BaseApk import ApkInfo
from Base.BaseLog import Log
import configparser as cfgparser
import os
import unittest
import time

logger = Log('runAll.py').get_log()

PATH = lambda p: os.path.abspath(os.path.join(os.path.dirname(__file__), p))
cfg = cfgparser.ConfigParser()
cfg.read(PATH('./config.ini'), encoding='utf-8')
t_case_path = cfg.get('T_CASE_PATH', 'path')
# p_case_path = cfg.get('P_CASE_PATH', 'path')
res_path = cfg.get('RESULT_PATH', 'path')
run_type = cfg.get('APP_TYPE', 'role_lst')
opt_method = cfg.get('OUTPUT', 'method')


def get_discover(_role):
    """
    get discover
    :param _role:
Beispiel #5
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@Author: Lidi
@Time  : 2019/5/19 22:02
@Desc  : Encapsulation of base adb command
"""

import os
import subprocess
from Base.BaseLog import Log

logger = Log('Baseadb.py').get_log()


class AdbOperate(object):

    """The class is aimed at encapsulating base adb command """

    @staticmethod
    def adb(cmd):
        """
        return the result of executing command
        :param cmd:
        :return:
        """
        return os.popen('adb %s' % cmd, 'r')

    @staticmethod
    def get_device_id():
        """
Beispiel #6
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@Author: Lidi
@Time  : 2019/6/18 13:57
@Desc  : The module of encapsulating runner params
"""
from appium import webdriver
import configparser as cfgparser
from Base.BaseLog import Log
import unittest
import os

# Initial logger
logger = Log('BaseRunner.py').get_log()
# Structure abspath by lambda method
PATH = lambda p: os.path.abspath(os.path.join(os.path.dirname(__file__), p))
# Initial cfgparser
cfg = cfgparser.ConfigParser()
cfg.read(PATH('../config.ini'), encoding='utf-8')


def appium_desired_caps(devices):

    desired_caps = {}
    desired_caps['platformName'] = devices['platformName']
    desired_caps['deviceName'] = devices['deviceName']
    desired_caps['platformVersion'] = devices['platformVersion']
    desired_caps["automationName"] = devices['automationName']
    desired_caps['appPackage'] = devices['appPackage']
    desired_caps['appActivity'] = devices['appActivity']
Beispiel #7
0
@Author: Lidi
@Time  : 2019/5/19 22:01
@Desc  : The module of Encapsulating Ui element operation
"""

from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import NoSuchElementException, \
    TimeoutException, WebDriverException, StaleElementReferenceException
from Base.BaseLog import Log
import configparser as cfgparser
import os
import time

logger = Log('BaseOperate.py').get_log()
PATH = lambda p: os.path.abspath(os.path.join(os.path.dirname(__file__), p))
screenshot_path = PATH('../Result/screenshot/')
if not os.path.exists(screenshot_path):
    os.mkdir(screenshot_path)

NOW = lambda: time.strftime('%Y%m%d%H%M%S')


class BaseOperate(object):
    """"""
    def __init__(self, driver):
        self.driver = driver
        self.cfg_path = PATH('../config.ini')
        self.cfg = cfgparser.ConfigParser()
        self.cfg.read(self.cfg_path, encoding='utf-8')
Beispiel #8
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@Author: Lidi
@Time  : 2019/5/19 23:59
@Desc  : Get apk package and activity
"""

import re
import os
import subprocess
from Base.BaseLog import Log

logger = Log('BaseApk.py').get_log()


class ApkInfo(object):

    """class of get apk's info"""

    def __init__(self, apk_path):
        """
        initial apk path
        :param apk_path:
        """
        self.apk_path = apk_path
        logger.info('apk path: %s' % self.apk_path)

    def get_appPackage(self):
        """
        get package name
Beispiel #9
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@Author: Lidi
@Time  : 2019/6/18 20:23
@Desc  : The module of page base operating
"""
from Base.BaseOperate import BaseOperate
from Base.BaseGetParams import GetParams
from Base.BaseLog import Log
import re

logger = Log('Pages.py').get_log()


class PageObjects(object):
    """
    The class of base page operate
    """
    def __init__(self, kwargs):
        self.driver = kwargs["driver"]
        self.fp = kwargs['data_path']
        self.sheet = kwargs['sheet']
        self._operate = BaseOperate(self.driver)
        self.cases = GetParams(self.fp, self.sheet)

    def operate(self):
        """
        execute operated cases
        :return:
        """