如何使用剧作家/测试运行程序生成 Allure HTML 报告?
我们计划使用 Nodejs、Typescript 和 Playwright 推荐的测试运行程序 (playwright/test),但无法找到任何有关如何使用上述技术堆栈生成 Allure HTML 报告的文档。还有其他报告格式,例如 json 和 junit,但我们希望生成 Allure HTML 报告,并希望附加失败测试用例的屏幕截图和视频。任何参考都会非常有帮助。
我有一个场景,其中 API 接收多个响应(一次一个)并在 UI 上呈现。API 继续轮询数据库,直到接收完所有响应为止。我需要我的脚本等待 API 响应变为“完成”。我尝试了下面的代码,但它没有等到状态完成。
const response = await page.waitForResponse(response => response.url().includes('https://services/url') && response.status() === 200);
console.log('RESPONSE ' + (await response.body()));
Run Code Online (Sandbox Code Playgroud)
以下是记录的响应
{
"transactionDetail": {
"transactionID":"866f357f-7541-4ff2-b879-61ca284513a7",
"transactionTimestamp":"2021-08-02T10:48:50.372207",
"inLanguage":"en-US",
"serviceVersion":"1"
},
"resultSummary":{
"inputCount":1,
"successCount":1,
"failureCount":0},
"inquiryDetail": {
"kaseIterationId":"8a7b11547af8835d017b067ad06e04ba"
},
},
"response":"InProgress"
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能让我的脚本等到“响应”变成“已完成”而不是“进行中”。
我正在尝试使用 Playwright (.NET) 抓取一个网站。该网站看起来像是在 2000 年代初编写的(以怪异模式等运行),而我遇到了一个我似乎无法找到解决方案的问题。
我的目标是选中一个复选框。我可以input使用选择元素
var input = await page.QuerySelectorAsync("inputSelector")
Run Code Online (Sandbox Code Playgroud)
该元素已成功选择,但在尝试运行时await input.CheckAsync(),出现错误Element is not attached to the DOM。我没有注意到会导致这种情况的元素有任何异常。为什么会发生此错误?
await page.ClickAsync("inputSelector")我通过运行来检查该框来使其工作。这适用于我的目的,但它不能解释为什么如果以其他方式完成它会出错,所以我仍然想知道为什么会发生该错误。
c# webautomation playwright playwright-sharp playwright-dotnet
将其发布到 Azure 云后,我无法运行调用剧作家测试的 azure 函数。
\n异常如下
\n Playwright Test or Playwright was just installed or updated. \n\xe2\x95\x91 \xe2\x95\x91 Please run the following command to download new browsers: \xe2\x95\x91 \xe2\x95\x91 \n\xe2\x95\x91 \xe2\x95\x91 playwright install \xe2\x95\x91 \xe2\x95\x91 \n\xe2\x95\x91 \xe2\x95\x91 <3 Playwright Team \xe2\x95\x91\nRun Code Online (Sandbox Code Playgroud)\n问题是我不知道如何运行playwright install。
有一些远程构建的可能性,但文档不包含详细信息。
\n所以我尝试遵循
\n%USERPROFILE%\\AppData\\Local\\ms-playwright\\chrome-win到项目文件夹中。.csproj后 chrome 浏览器将位于输出目录并输出 zip<ItemGroup>\n <Content Include="chrome-win\\**">\n <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>\n </Content>\n</ItemGroup>\nRun Code Online (Sandbox Code Playgroud)\n我想使用Playwright为我的 Angular 应用程序运行端到端 (e2e) 浏览器测试。然而,截至 2021 年 11 月,我尚未找到 Playwright 的 Angular 示意图。
例如, Cypress有一个官方的 Angular Schematic 。这使得可以使用以下命令运行赛普拉斯 e2e 测试:
ng e2e
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以在不编写 Angular 原理图的情况下使用 Playwright 运行 Angular e2e 测试?或者我错过了 Playwright 的 Angular 示意图吗?
e2e-testing angular-cli angular angular-schematics playwright
我单击触发 http 请求的按钮\n并且我希望能够在请求完成后关闭页面。
\n示例:\nAwait page.click(触发http请求的某个按钮)
\n我已经尝试过:Await page.waitForLoadState()\nWith \xe2\x80\x9cload\xe2\x80\x9d 和 \xe2\x80\x9cnetworkidle\xe2\x80\x9d 并且它不起作用。\n对于加载页面,没有关闭请求完成并等待网络空闲直到超时。
\n我希望能够等待后台所有的xhr请求完成
\n我正在使用 Playwright 进行端到端测试。其中一种场景涉及检查 PDFviewer 窗口中显示的 pdf 内容,该窗口的下载按钮已对最终用户隐藏。检查 pdf 内容需要下载它,因此我使用\nforce文档提到的选项:\n https://playwright.dev/docs/api/class-page#page-click
使用的实现如下:
\ninnerFrameContent.click("//button[contains(@id, \'secondaryDownload\')]", { force: true })\nRun Code Online (Sandbox Code Playgroud)\n(xpath是正确的,我在Chrome浏览器中检查并设法通过控制台单击该元素)
\n不幸的是,我从 Playwright 收到以下异常日志:
\nframe.click: Element is not visible\n=========================== logs ===========================\nwaiting for selector "//button[contains(@id, \'secondaryDownload\')]"\n selector resolved to hidden <button tabindex="54" title="Download" id="secondaryDown\xe2\x80\xa6>\xe2\x80\xa6</button>\nattempting click action\n waiting for element to be visible, enabled and stable\n forcing action\n element is visible, enabled and stable\n scrolling into view if needed\n============================================================\n...\nRun Code Online (Sandbox Code Playgroud)\n 我正在尝试导入剧作家框架。但是,我遇到了以下问题:
Traceback (most recent call last):
File "simple.py", line 1, in <module>
from playwright.sync_api import sync_playwright
ImportError: cannot import name 'sync_playwright' from 'playwright.sync_api' (/home/acid/dev/play/venv
/lib/python3.8/site-packages/playwright/sync_api.py)
Run Code Online (Sandbox Code Playgroud)
我已经通过以下命令安装了剧作家:
pip install playwright==1.8.0a1
playwright install
Run Code Online (Sandbox Code Playgroud)
然后,运行脚本:
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
for browser_type in [p.chromium, p.firefox, p.webkit]:
browser = browser_type.launch()
page = browser.new_page()
page.goto('http://whatsmyuseragent.org/')
page.screenshot(path=f'example-{browser_type.name}.png')
browser.close()
Run Code Online (Sandbox Code Playgroud)
然而,仍然没有成功。对于这个问题你有什么建议吗?提前致谢
为项目配置和使用 url 的最佳方法是什么
...作为示例,我们有这样的情况
水果应用程序
色彩应用程序
...和这样的测试
test('Navigate to fruits/banana', async () => {
await page.goto('https://https://dev.fruits.com/banana/');
...
});
test('Navigate to colors/red', async () => {
await page.goto('https://https://dev.colors.com/red/');
...
});
Run Code Online (Sandbox Code Playgroud)
...我想去的地方
我正在同时学习 Playwright 和 JavaScript,所以这可能是一个基本问题 - 我想知道人们如何建议customerId在测试之间共享状态 - 在这种情况下是变量。
例子:
test.describe.only('Generate a new customer', () => {
let customerId
let baseUrl = process.env.SHOP_URL
test('Create new customer', async ({ request }) => {
const response = await request.post(baseUrl + `/shopify/v5/customer`, {})
const responseBody = JSON.parse(await response.text())
expect(response.status()).toBe(200)
customerId = responseBody.customerId //need to persist customerId to pass into following test
})
test('Update customer details', async ({ request }) => {
const response = await request.post(baseUrl + `/shopify/v5/customer/update`, {})
{
data: { …Run Code Online (Sandbox Code Playgroud) playwright ×10
angular ×2
javascript ×2
allure ×1
angular-cli ×1
base-url ×1
c# ×1
e2e-testing ×1
html ×1
node.js ×1
protractor ×1
python ×1
typescript ×1