def action():
    env = Environment().get_environment_info()

    allure.environment(app=env.apk)
    allure.environment(app_activity=env.app_activity)
    allure.environment(device_name=env.devices[0].device_name)
    allure.environment(platform_name=env.devices[0].platform_name)
    allure.environment(platform_version=env.devices[0].platform_version)

    capabilities = {
        'platformName': env.devices[0].platform_name,
        'platformVersion': env.devices[0].platform_version,
        'deviceName': env.devices[0].device_name,
        'app': env.apk,
        'clearSystemFiles': True,
        'appActivity': env.app_activity,
        'appPackage': env.app_package,
        'automationName': 'UIAutomator2',
        'newCommandTimeout': "2000",
        'unicodeKeyboard': True,
        'resetKeyboard': True,
        'noSign': True,
        'autoGrantPermissions': True
    }
    host = "http://localhost:4724/wd/hub"
    driver = webdriver.Remote(host, capabilities)
    yield ElementActions(driver).reset(driver)
    driver.quit()
Example #2
0
    def driver(self, request, device_logger, device):
        p = subprocess.Popen('ttab -w "/usr/local/bin/appium '
                             '--address 127.0.0.1 --chromedriver-port 9516 --bootstrap-port 4725 --no-reset '
                             '--local-timezone"', shell=True, stdin=subprocess.PIPE)

        sleep(10)

        allure.environment(Device='Android emulator', Version='Android 6.0', Type='Demo')

        # calling_request = request._pyfuncitem.name

        driver = webdriver.Remote(APPIUM_LOCAL_HOST_URL, reader.cap_reader(reader(), device))

        driver.implicitly_wait(10)

        driver.close_app()

        def fin():
            # take_screenhot_and_logcat(driver, device_logger, calling_request)
            driver.remove_app('com.example.android.apis')
            driver.quit()
            os.system('./script/stopAppium.sh')

        request.addfinalizer(fin)
        return driver
Example #3
0
def pytest_configure(config):
    allure.environment(
        report='Castlighthealth',
        url='https://us.castlighthealth.com',
        browser=u'Google Chrome',
        environment="remote",
    )
Example #4
0
def api(optns, request):
    """
    :param optns:
    :param request:
    :return:
    """
    allure.environment(report='Allure report', server=optns['base_url'])
    return Application(optns)
def env(request):
    """
    Parse env config info
    """
    host_config = ConfHost()
    host = host_config.get_host_conf()
    allure.environment(test_platform=host["test_platform"])
    allure.environment(mock=host["mock"])
Example #6
0
 def set_allure_env(service='Service', **kwargs):
     #log.debug('[set_allure_env] service: ' + str(service))
     #log.debug('[set_allure_env] kwargs: ' + str(kwargs.items()))
     for key, value in kwargs.items():
         allure_key = str(service) + '_' + str(key)
         #kwargs[allure_key] = kwargs.pop(key)
         dict = {}
         dict[allure_key] = value
         #log.debug('[set_allure_env] kwargs: ' + str(kwargs.items()))
         allure.environment(**dict)
Example #7
0
def test_minor():
    allure.environment(country='countrys')
    with allure.step("步骤一"):
        @allure.attach("说明这个步骤", "???")
        assert True
    with allure.step("步骤二", "???"):
        @allure.attach("说明")
        assert True
    with allure.step("步骤三", "???"):
        @allure.attach("说明")
        assert False
Example #8
0
def action():
    # 定义环境
    env = Consts.API_ENVIRONMENT_ACTIVITY
    # 定义报告中environment
    conf = Config()
    host = conf.host_test
    tester = conf.tester_test
    allure.environment(environment=env)
    # allure.environment(hostname=host)
    # allure.environment(tester=tester)
    return env
Example #9
0
def env(request):
    """
    Parse env config info
    """
    root_dir = request.config.rootdir
    config_path = '{0}/config/env_config.yml'.format(root_dir)
    with open(config_path) as f:
        env_config = yaml.load(f)  # 读取配置文件

    allure.environment(host=env_config['host']['domain'])  # 测试报告中展示host
    allure.environment(browser=env_config['host']['browser'])  # 测试报告中展示browser

    return env_config
Example #10
0
def driver(browser_type, base_url, remote, selenium_hub):
    """Драйвер браузера"""
    if browser_type == 'firefox':
        browser = browsers.get_firefox(remote=remote,
                                       selenium_hub=selenium_hub)
    else:
        raise ValueError('Browser "{:s}" not supported'.format(browser_type))
    allure.environment(
        browser=browser.capabilities['browserName'],
        version=browser.capabilities['version'],
        platform=browser.capabilities['platform'],
    )
    browsers.set_webdriver(browser)
    browser.maximize_window()
    browser.get(base_url)
    yield browser
    browser.quit()
Example #11
0
def pytest_configure(config):
    update_config_by_environment(config_common, config.getoption("--env"))

    set_options(config, option_list)
    # set log level
    setLogLevel(config_common.get("DEFAULT", "log_level"))

    # just show properties in allure report
    deprecated = [
        k for k, _ in config_common.items('DEFAULT')
        if ('password' in k or 'secret' in k)
    ]
    data = {
        name: value
        for name, value in config_common.items('DEFAULT')
        if name not in deprecated
    }
    allure.environment(**data)
Example #12
0
def test_case_example(para_one, para_two):
    """用例描述:测试字符串相等
    :param para_one: 参数1
    :param para_two: 参数2
    """

    # 获取参数
    paras = vars()
    # 报告中的环境参数,可用于必要环境参数的说明,相同的参数以后者为准
    allure.environment(host="172.6.12.27", test_vars=paras)
    # 关联的资料信息, 可在报告中记录保存必要的相关信息
    allure.attach("用例参数", "{}".format(paras))  # format函数依次填充参数
    # 调用测试函数
    res = str_add(para_one, para_two)
    # 对必要的测试中间结果数据做备份
    allure.attach("str_add返回结果", "{}".format(res))
    # 测试步骤,对必要的测试过程加以说明
    with allure.step("测试步骤2,结果校验 {0} == {1}".format(res, para_one + para_two)):
        assert res == para_one + para_two, res
Example #13
0
def driver(device):
    if browser_flag().lower() != 'n':
        driver_instance = get_webdriver(device)
    if browser_flag().lower() == 'n':
        caps = DesiredCapabilities.CHROME
        caps["pageLoadStrategy"] = "none"
        caps["version"] = "65.0"
        caps["browserName"] = "chrome"
        driver_instance = webdriver.Chrome(desired_capabilities=caps)
    try:
        yield driver_instance
    finally:
        console_log = driver_instance.get_log('browser')
        allure.attach('console log', str(console_log))
        allure.attach('screenshot',
                      driver_instance.get_screenshot_as_png(),
                      type=AttachmentType.PNG)
        allure.environment(
            browser=driver_instance.desired_capabilities['browserName'] + ' ' +
            driver_instance.desired_capabilities['version'])
        driver_instance.quit()
def action():
    # 定义环境
    env = Consts.API_ENVIRONMENT_DEBUG
    conf = Config()
    host = conf.host_debug
    tester = conf.tester_debug
    allure.environment(environment=env)
    allure.environment(hostname=host)
    allure.environment(tester=tester)
    return env
Example #15
0
def action():
    #定义环境
    env = Consts.API_ENVIRONMENT_RELEASE
    conf = Config()
    host = conf.host_relese
    tester = conf.tester_release
    allure.environment(environment=env)
    allure.environment(hostname=host)
    allure.environment(tester=tester)

    return env
Example #16
0
class Test():

    paras = {'测试环境': '小峰峰本地机器'}
    # 报告中的环境参数,可用于必要环境参数的说明,相同的参数以后者为准
    allure.environment(host="172.0.0.1", test_vars=paras)

    @allure.severity("blocker")
    @allure.issue("http://www.panda.tv")
    @allure.testcase("测试用例:test1")
    @allure.feature("小峰峰测试功能")
    @allure.story("小峰峰功能1")
    # @pytest.mark.parametrize("x", ["this"], ids=["学习1"])
    @allure.step("运算:x+y")
    def test_1(self):
        """测试用例1"""
        x = 2
        y = 4
        paras = vars()
        allure.attach("用例参数", "{0}".format(paras))
        allure.attach("返回结果", "{0}".format(6))
        assert 6 == x + y, 6

    @allure.severity("blocker")
    @allure.issue("http://www.panda.tv")
    @allure.testcase("测试用例:test2")
    @allure.feature("小峰峰测试功能")
    @allure.story("小峰峰功能2")
    def test_2(self):
        """打开pandatv首页"""
        driver = webdriver.Firefox()
        driver.get('https://www.baidu.com')
        driver.find_element_by_id('kw').send_keys('hello')
        driver.find_element_by_id('su').click()
        time.sleep(5)
        driver.save_screenshot("./report/b.png")
        f = open('./report/b.png', 'rb').read()
        allure.attach('this is a img', f, allure.attach_type.PNG)

        driver.quit()
Example #17
0
def test_case_01():
    """
    用例描述:此段为测试用例的描述
    :return:
    """
    allure.environment(host='127.0.0.1')  # 测试报告中展示environment配置的环境变量,随意命名
    host_name = "my.host.local"
    allure.environment(hostname=host_name)
    allure.environment(report='Allure report', browser=u'Я.Браузер')
    allure.environment(alibaba='杭州阿里巴巴集团')

    with allure.step("第一步:浏览商品"):  # 将一个测试用例分成几个步骤,将步骤打印到测试报告中
        allure.attach('商品1', '康师傅')  # attach可以向测试报告中输入一些附加的信息
        allure.attach('商品2', '冰红茶')
        allure.attach('商品3', '酒鬼花生')
    with allure.step("第二步:点击商品"):  # 将一个测试用例分成几个步骤,将步骤打印到测试报告中
        file = open('./藏狐.jpg', 'rb').read()  # attach向测试报告中输入图片附件信息
        allure.attach('test_img', file, allure.attach_type.JPG)
        allure.attach('test_img', file, allure.attach_type.JPG)
        pass
    with allure.step("第三步:校验结果"):
        allure.attach('期望结果', '添加商品列表成功')
        allure.attach('实际结果', '添加商品列表失败')
        assert 'success' == 'failed'
Example #18
0
def init_allure_env():
    printWithPrefix('[init_allure_env] invoked.')
    allure.environment(report='Allure report', hostname='zhengjin.host.local')
Example #19
0
def allure_config():
    # setup allure environment
    allure.environment(report=env('Web_ENV')+"Web Automation",
                       browser=env('SELENE_BROWSER_NAME'),
                       hostname=env('SELENE_BASE_URL'))
Example #20
0
def env(request):
    env_config = YamlReader('config.yml').get_data('env')
    allure.environment(host=env_config)
    return env_config
Example #21
0
    class ACCOUNT:
        CRM_USER = '******', '123456'


class Online:

    # data_mock
    DATS_MOCK_HOST = "http://lvjunjie.cn:5000"

    class ACCOUNT:
        CRM_USER = '******', '123456'


CONFIG = Test

BUILD_USER = os.getenv('BUILD_USER', 'tester')
if BUILD_USER == '':
    BUILD_USER = '******'

environment = os.getenv('environment', 'test')

if environment == 'test':
    CONFIG = Test
else:
    CONFIG = Test

allure.environment(测试环境=environment,
                   host=CONFIG.DATS_MOCK_HOST,
                   执行人=BUILD_USER,
                   测试项目='DMP后台接口')
Example #22
0
def action():
    # 定义环境
    # 定义报告中environment
    host = confRead.Config().read_host()
    allure.environment(hostname=host)
Example #23
0
from libs.auth import auth
from django.conf import settings
from unittest import TestCase
from django.conf import settings
from libs.notam import NotamTest
import libs.notam
from allure_commons._allure import epic, feature, story

config = {'host': 'notamdev.qantor.ru', 'schema': 'https', 'port': 443}

auth = auth('admin', 'admin', False)
logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)

logger = logging.getLogger(__name__)

allure.environment('user', 'admin')
allure.environment('pass', 'admin')


@pytest.fixture(scope='module')
def web_driver():
    token = libs.notam.auth_key()
    auth.use = True
    auth.token = token
    logger.debug('[test_one] token: ' + str(token))
    logger.debug('[test_one] auth.token: ' + str(auth.token))
    driver = WebDriver(schema=config.get('schema'),
                       host=config.get('host'),
                       port=config.get('port'),
                       authorise=auth,
                       content='application/json')
Example #24
0
def pytest_configure(config):
    allure.environment(test_server='testserver', report='My Test Report')
Example #25
0
from nose.tools import assert_dict_contains_subset
from nose.tools import assert_in

from nose.tools import assert_dict_equal
from nose.plugins.skip import SkipTest
import logging
logger = logging.getLogger(__name__)  # 日志中:日志器名称为模块名,每个模块运行时显示各自的模块名称

# set_trace()
#test_demo01加入了sys.path,就可以通过下面的方式导入一个类,此时会执行被导入类的import部分
from common.open_execl_xlrd_ok import Open_excel
#导入request请求的类
from request.request_method import Request_method
# set_trace()
# 具体Environment参数可自行设置
allure.environment(app_package='com.mobile.fm')
allure.environment(app_activity='com.mobile.fm.activity')
allure.environment(device_name='aad464')
allure.environment(platform_name='Android')
p1 = sys.getdefaultencoding()
import sys
reload(sys)
sys.setdefaultencoding('utf8')
p2 = sys.getdefaultencoding()
print p1
print p2
'''
问题:
w10系统,cmd运行下面代码
set_trace()
logger.info(u'Test_api006接口开始测试...')
Example #26
0
def pytest_configure(config):
    allure.environment(test_url=os.getenv("TEST_URL") or 'www.schireson.com')
Example #27
0
# coding=utf-8
# author='Shichao-Dong'
# create time: 2019/1/10
'''
pip3 install pytest-allure-adaptor

然后安装allure-commandline
'''

import allure
import pytest


@allure.story('story_1')
@allure.severity('normal')
@allure.step("描述")
def test_add():
    '''
    判断两个是否相等
    '''
    assert 1 == 1


allure.environment(app_package='com.qukan.kdd')
allure.environment(app_activity='com.qukan.kdd.activity')
allure.environment(device_name='huawei')
allure.environment(platform_name='Android')
Example #28
0
def init_allure_env():
    allure.environment(report='Allure report',
                       browser='Firefox',
                       hostname='zhengjin.host.local')
Example #29
0
import allure

# Can be one of ['firefox', 'chrome', 'ie32', 'ie64']
BROWSER_NAME = 'firefox'

allure.environment(browser=BROWSER_NAME)
def test_store_environment():
    allure.environment(foo='bar', country=u'Россия')
    assert True