我试图用图表填充我的诱惑报告,但仅显示默认值(严重性和持续时间)。
我查看了 allure-reports/widgets,json 文件在那里,但仍然没有显示在网页上。
顺便说一句,概述中的趋势部分也是空的。
我正在使用 allure 2.5.0 和 python-behave
我有一个 python Web 应用程序,它使用Behavior 进行行为测试。我有 5 个 *.feature 文件,当我在本地和我们的 Jenkins 构建服务器上运行它们时,每个文件都需要几分钟才能运行。我想并行运行这五个文件而不是顺序运行以节省时间。我可以在本地执行此操作,但不能在我的构建服务器上执行此操作。详细信息如下:
在 Windows 上本地运行:
behave.exe --include "file_01.feature"behave.exe --include "file_02.feature"behave.exe --include "file_03.feature"behave.exe --include "file_04.feature"behave.exe --include "file_05.feature"构建服务器在 Linux 上运行:
当我尝试使用类似的命令运行所有五个文件时,某些行为场景会出现错误。错误是以下三个之一:
抛出这些错误的行为场景似乎随着每次测试运行而改变。
我怀疑在运行行为测试中 Chrome 驱动程序之间存在一些共享资源,但我不确定。我无法解释为什么这在本地适用于我,但在我的构建服务器上却不起作用。我也无法解释为什么 3 个文件可以工作,但 5 个文件就不行。
在尝试同时运行多个行为测试时,有人看到过这样的错误吗?或者你知道我应该寻找什么吗?我的项目足够大,很难将我的问题的最小示例放在一起。这就是为什么我没有发布任何代码。我只是想知道我应该寻找什么,因为我不知所措。
我正在构建一个 Py Behave 测试框架,并且有许多场景,其中以前的“何时”步骤变成了“给定”步骤
EG 在一种情况下
Given a user has is on the logon page
When they login with credentials <user>
Then the user logs in
Run Code Online (Sandbox Code Playgroud)
但在其他场景下
Given a user is on the logon page
And they login with credentials <user>
Run Code Online (Sandbox Code Playgroud)
在我的步骤中,这将显示为
@given('they login with credentials {user}')
def step_impl(context):
Do login code
@when('they login with credentials {user}')
def step_impl(context):
Do login code
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以避免将所有这些步骤写两次,但能够将何时定义为给定?
您好:/我目前在项目中设置下载文件夹时遇到问题。
我正在使用 Mac、Pycharm CE、Selenium、Python、Behave 和 Firefox(项目要求)。
我尝试了此配置Python Selenium Firefox 下载目录出现问题,但我不确定我做错了哪一部分。:/ 下载的文件仍位于默认的下载文件夹中。
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
@given("First step")
def step_impl(context):
download_path = "/Users/this/is/the/absolute/path/downloads"
options = Options()
options.set_preference("browser.download.folderList", '2')
options.set_preference("browser.download.manager.showWhenStarting", False)
options.set_preference("browser.download.dir", download_path)
options.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/csv")
context.driver = webdriver.Firefox(options=options)
Run Code Online (Sandbox Code Playgroud) 现在,我具有以下测试功能目录:
Tests/
--BehaveTest1/
----BehaveTest1.feature
----steps/
------test_steps.py
--BehaveTest2/
----BehaveTest2.feature
----steps/
------test_steps.py
Run Code Online (Sandbox Code Playgroud)
由于BehaveTest1和BehaveTest2的测试步骤很常见,因此我想实现一个通用模块,两个测试用例都可以在需要时调用它们。目前,我已经在Tests /文件夹中建立了common /目录,并通过以下方式将其导入(每个测试功能的test_steps.py文件中):
import sys, os
sys.path.append('../common')
import common
Run Code Online (Sandbox Code Playgroud)
但是我不想弄乱路径,所以我想知道是否有更好的方法可以通过行为测试功能的结构来做到这一点?
我开始使用行为和硒来编写自动测试。我想创建名为 url 的参数作为配置参数,并且: - 能够将其设置为默认值 - 能够将其作为参数从命令行传递
我知道我应该能够使用 userdata 来实现这一点,但我无法弄清楚究竟是如何实现的。有人可以帮忙吗?:)
当我从这里使用此步骤两次时:
$ behave -f allure_behave.formatter:AllureFormatter -o %allure_result_folder% ./features
Run Code Online (Sandbox Code Playgroud)
进而
$ allure serve %allure_result_folder%
Run Code Online (Sandbox Code Playgroud)
总是有 1 个测试用例。我怎样才能设法总结测试用例?我想看测试用例。
我也运行了两次此代码:
behave -f allure_behave.formatter:AllureFormatter -o results ./features
Run Code Online (Sandbox Code Playgroud)
进而:
allure generate results/ -o report/
Run Code Online (Sandbox Code Playgroud)
但是,我仍然只有 1 个测试用例。
我想看到例如 类似的结果
我无法找到一种方法如何使用beeve.iniApiClient的值来初始化我的context.config.userdata['url']
行为.ini
[behave.userdata]
url=http://some.url
Run Code Online (Sandbox Code Playgroud)
步骤.py
from behave import *
from client.api_client import ApiClient
# This is where i want to pass the config.userdata['url'] value
api_calls = ApiClient('???')
@given('I am logged as "{user}" "{password}"')
def login(context, user, password):
context.auth_header = api_calls.auth(user, password)
Run Code Online (Sandbox Code Playgroud)
api_client.py
class ApiClient(object):
def __init__(self, url):
self.url = url
def auth(self, email, password):
auth_payload = {'email': email, 'password': password}
auth_response = requests.post(self.url + '/api/auth/session', auth_payload)
return auth_response.text
Run Code Online (Sandbox Code Playgroud) 我从Python Behave开始,因为我想做一个API测试的事情.
目前我偶然发现了一些可能甚至无效的问题,但问题是:我可以在功能之间共享数据吗?我可以在数据库或文件中存储一些,但也许有"内置"的东西?
或者这是无效的,我不应该分享这样的数据,或者可能在功能内部?
在实践中它看起来像:
我必须向端点发出请求,在响应中我得到一个需要进行另一个需要测试的请求的号码.
Python BDD框架Behave在其中有以下代码 runner.py
with open(filename) as f:
# -- FIX issue #80: exec(f.read(), globals, locals)
# try:
filename2 = os.path.relpath(filename, os.getcwd())
code = compile(f.read(), filename2, 'exec')
Run Code Online (Sandbox Code Playgroud)
如您所见,没有提供字符集open.根据其文档,locale.getpreferredencoding用于此类案件.
但在Windows上,此函数始终返回一个字节的字符集(所谓的"非字符串程序的字符集").适用于拉丁语的Windows-1252,适用于西里尔语的Windows-1251等.
因此,UTF-8 py文件总是被破坏.
我的问题是,如果想要超出1字节字符集,我如何在Windows上使用非脚本步骤定义?
python-behave ×10
python ×7
selenium ×3
allure ×2
bdd ×1
firefox ×1
graph ×1
jenkins ×1
linux ×1
python-2.7 ×1
python-3.x ×1
report ×1
unicode ×1
windows ×1