|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
直接上源码import pytest
from py.xml import html
from config import RunConfig
import allure
from slugify import slugify
from common.config import *
from playwright.sync_api import sync_playwright, expect
# 定义基本测试环境
@pytest.fixture(scope='session')
def base_url():
return RunConfig.baseUrl
import os
from common.config import *
'''
运行测试配置
'''
class RunConfig:
# 运行测试用例的目录或文件
# case_path = os.path.join(case_path, "test_case")
cases_path = os.path.join(case_path, "test_demo.py")
#
# 配置浏览器驱动类型(chromium, firefox, webkit)
browser = "chromium"
# 运行模式(headless, headful)
# mode = "headless"
mode = "headful"
# 配置运行的 URL
baseUrl = "XXX"
# 失败重跑次数
rerun = "0"
# 当达到最大失败数,停止执行
max_fail = "5"
# 报告路径(不需要修改)
NEW_REPORT = None
import sys
from time import sleep
from playwright.async_api import Dialog
from seldom.testdata.conversion import json_to_list
from page.element import Element
import allure
import pytest
from common.config import *
@allure.feature('平台基础测试')
class TestPlatformFoundation():
@allure.story("test001-平台登录")
def test_platform_foundation_001(self, page, base_url):
"""
名称:平台登录
步骤:
1、打开浏览器
2、输入账号
3、输入密码
4、点击登录
检查点:
* 检查登录是否成功
"""
page.goto(base_url)
报错如下:Traceback (most recent call last):
File "D:\Program Files\JetBrains\PyCharm 2021.3.2\plugins\python\helpers\pycharm\_jb_pytest_runner.py", line 51, in <module>
sys.exit(pytest.main(args, plugins_to_load + [Plugin]))
File "D:\python\lib\site-packages\_pytest\config\__init__.py", line 147, in main
config = _prepareconfig(args, plugins)
File "D:\python\lib\site-packages\_pytest\config\__init__.py", line 328, in _prepareconfig
config = pluginmanager.hook.pytest_cmdline_parse(
File "D:\python\lib\site-packages\pluggy\hooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "D:\python\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "D:\python\lib\site-packages\pluggy\manager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "D:\python\lib\site-packages\pluggy\callers.py", line 203, in _multicall
gen.send(outcome)
File "D:\python\lib\site-packages\_pytest\helpconfig.py", line 103, in pytest_cmdline_parse
config: Config = outcome.get_result()
File "D:\python\lib\site-packages\pluggy\callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "D:\python\lib\site-packages\pluggy\callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "D:\python\lib\site-packages\_pytest\config\__init__.py", line 1075, in pytest_cmdline_parse
self.parse(args)
File "D:\python\lib\site-packages\_pytest\config\__init__.py", line 1425, in parse
self._preparse(args, addopts=addopts)
File "D:\python\lib\site-packages\_pytest\config\__init__.py", line 1305, in _preparse
self.pluginmanager.load_setuptools_entrypoints("pytest11")
File "D:\python\lib\site-packages\pluggy\manager.py", line 299, in load_setuptools_entrypoints
plugin = ep.load()
File "D:\python\lib\importlib\metadata.py", line 86, in load
module = import_module(match.group('module'))
File "D:\python\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'pytest_base_url'
进程已结束,退出代码1
空套件
|
|