我有一个页面,我需要在其中选择一个链接。页面上的链接是(例如):
<a href="/animation?ID=11111\&model\_id=AAAAA">Preview Results</a>
<a href="/animation?ID=11111\&model\_id=BBBBB">Preview Results</a>
<a href="/animation?ID=22222\&model\_id=CCCCC">Preview Results</a>
<a href="/animation?ID=22222\&model\_id=DDDDD">Preview Results</a>
<a href="/animation?ID=33333\&model\_id=EEEEE">Preview Results</a>
<a href="/animation?ID=33333\&model\_id=FFFFF">Preview Results</a>
Run Code Online (Sandbox Code Playgroud)
我需要的链接是第一个实例ID=22222
我可以获得第一个预览结果链接:
<a href="/animation?ID=11111\&model\_id=AAAAA">Preview Results</a>
<a href="/animation?ID=11111\&model\_id=BBBBB">Preview Results</a>
<a href="/animation?ID=22222\&model\_id=CCCCC">Preview Results</a>
<a href="/animation?ID=22222\&model\_id=DDDDD">Preview Results</a>
<a href="/animation?ID=33333\&model\_id=EEEEE">Preview Results</a>
<a href="/animation?ID=33333\&model\_id=FFFFF">Preview Results</a>
Run Code Online (Sandbox Code Playgroud)
但是我怎样才能获得第一个ID链接(ID 22222
)?
我所期望的 我尝试与基于角度的网页上的滑块 ui 元素进行交互。下面显示的代码不再与有问题的元素交互。曾经有一段时间..
更多信息
阅读提到的“空白”问题,这称为“视图跟踪”。我不能 100% 确定这与该问题有关。
我尝试过的
我在与使用 Angular 构建的网页上的滑块交互时遇到问题。通过我目前的解决方案
async slideToAgree() {
const { page } = this
const {
width: sw,
height: sh,
x: sx,
y: sy
} = await (await page.$('.slider-controller')).boundingBox();
const { width: tw, x: tx } = await (
await page.$('.slider-container')
).boundingBox();
await page.mouse.move(sx + sw / 2, sy + sh / 2);
await page.mouse.down();
await page.mouse.move(tx + tw, sy + sh / 2, { steps: 10 });
}
}
Run Code Online (Sandbox Code Playgroud)
实际发生了什么/结果
剧作家正在点击屏幕的右上角,在网页之外的这个奇怪的“额外空白区域”..让我觉得元素的边界框已损坏/未附加到 DOM? …
browser-automation uislider playwright playwright-typescript
我想检查文本内容是否为one
或two
:
await expect(this.header).toHaveText('one').or('two')
Run Code Online (Sandbox Code Playgroud)
有没有办法使用 Playwright 使其发挥作用?
这也可以在像这样的句子中实现
await expect(this.header).toHaveText("this is "+('first').or('second')+ "sentence");
Run Code Online (Sandbox Code Playgroud) 与剧作家一起进行屏幕截图测试的好方法是什么?
如果我真的理解的话,我需要截图,如下所示:
it('Some test', async () => {
page.screenshot({ path: 'screenshot.png' });
}
Run Code Online (Sandbox Code Playgroud)
但我如何将它与标准具屏幕截图进行比较呢?如果我错过了文档中的某些内容,请告诉我
我正在进行端到端 UI 测试,当我尝试为 Harmony Web UI 组件 (<ext-support_he-select>) 选择一个选项时,playwright 无法识别 customere 标签,并且错误提示不是选择选项。
我也无法使用无头录音机记录下拉选择选项,如果有人遇到过此类问题,请告诉我。
HTML 选择代码: { <ext-support_he-select id="workspace-dropdown" class="basic-dropdown basic-workspace-dropdown 低于有效" aria-labelledby="workspace-label" role="combobox" current-value= “” aria-controls =“” aria-disabled =“假” aria-expanded =“假” aria-haspopup =“列表框” tabindex =“0”位置=“下方” aria-activedescendant =“选项14”>
<ext-support_he-option selected="" value="" aria-selected="true" class="selected" role="option" id="option-14" aria-posinset="1" aria-setsize="9"> Select a Workspace </ext-support_he-option>
<ext-support_he-option value="accountPlans" aria-selected="false" role="option" id="option-15" aria-posinset="2" aria-setsize="9"> Account Plans </ext-support_he-option>
<ext-support_he-option value="accounts" aria-selected="false" role="option" id="option-16" aria-posinset="3" aria-setsize="9"> Accounts </ext-support_he-option>
<ext-support_he-option value="contacts" aria-selected="false" role="option" id="option-17" aria-posinset="4" aria-setsize="9"> Contacts </ext-support_he-option> …
Run Code Online (Sandbox Code Playgroud) 我收到此错误:
At line:1 char:1
+ playwright install
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (playwright:String) [],CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)
我使用 pip 安装它,以便在 python 中使用
我正在测试一个网站,该网站有一个需要打开或已经打开的列表。元素的类根据其当前所处的状态而变化。
所以该元素是
div class="list-open"
Run Code Online (Sandbox Code Playgroud)
或者
div class="list-closed"
Run Code Online (Sandbox Code Playgroud)
我的脚本必须检查这一点,以确保在列表关闭时打开列表以继续算法。我如何与 Playwright 检查班级名称?
我希望将我的测试套件从 Cypress 迁移到 Playwright。当我处理 API 请求时遇到了障碍。
在我的测试套件中,我想等待网络请求完成并返回 200 响应,然后再进行下一个操作。
我的问题是网络请求 url 包含动态值,之前在 Cypress 中我将“*”作为通配符,Playwright 中的替代方案是什么?
我的代码中有以下 cy.intercept:
cy.intercept('GET',`${apiUrl}/employee/*/information`).as('GETemployeeInformation');
Run Code Online (Sandbox Code Playgroud)
在继续测试步骤之前,我在测试套件中使用 cy.wait 调用此拦截,我尝试使用以下内容在 Playwright 中复制此内容:
async isSignedIn() {
await this.page.waitForResponse(response => response.url().includes("/employee/*/information") && response.status() === 200);
}
Run Code Online (Sandbox Code Playgroud) playwright ×8
javascript ×3
python ×2
automation ×1
cypress ×1
e2e-testing ×1
html ×1
pip ×1
testing ×1
typescript ×1
ui-testing ×1
uislider ×1