[Feature]: Implement hasAttribute(String)
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 45/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- java
- 领域
- testing-qa
调研方向
从 issue 中显示的 Java assertion 入口 PlaywrightAssertions.assertThat 开始,并检查现有的 hasAttribute 重载。确认 locator 属性不存在时的表示方式,并添加所请求的仅接收 String 的形式,以便无需值即可断言属性存在或不存在;完成的标准是 API 支持所示的 .not().hasAttribute("min") 用法。
由索引模型根据 Issue 内容生成。
描述
🚀 Feature Request
I want to check if a locator has an attribute.
I think that's what toHaveAttribute(name) is doing in typescript.
I tried to:
assertThat(getInputLocator()).not().hasAttribute("min", ""); // that will forbid empty min but not a filled value
or
assertThat(getInputLocator()).not().hasAttribute("min", Pattern.compile(".*"));
And the result is:
- unexpected value "undefined"
With a new API hasAttribute(String attributeName), I would be able to do:
assertThat(getInputLocator()).not().hasAttribute("min");
That will test if there is an attribute min.
Example
import com.microsoft.playwright.assertions.PlaywrightAssertions;
import java.util.regex.Pattern;
Locator el = page.locator("#my-el");
// Assert the attribute is NOT present:
PlaywrightAssertions.assertThat(el)
.not()
.hasAttribute("min", Pattern.compile(".*"));
Motivation
The only workaround I found is to get the attribute and asserts it's null. But it's not the good practice.
Having that will help to check to the absence of a attribute.
- 主要语言
- Java
- 星标
- 1.6k
- 派生
- 298
- 平均合并
- 3 天 2 小时
- 30 天内合并 PR
- 14
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/playwright-java 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 42/100
microsoft/playwright-java#1963 · 1 条评论 ·
-
P3-collecting-feedback
难度 5/5 一周以上 新手友好度 30/100
microsoft/playwright-java#1885 · 3 条评论 · 4 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 45/100
microsoft/playwright-java#1881 · 3 条评论 ·
-
难度 4/5 3-5 天 新手友好度 48/100
microsoft/playwright-java#1876 · 1 条评论 ·
-
P3-collecting-feedback
难度 3/5 1-2 天 新手友好度 48/100
microsoft/playwright-java#1875 ·
查看 microsoft/playwright-java 的全部 Issue
相似的 Issue
-
Bug Java Platform: Java
难度 2/5 1-3 小时 新手友好度 78/100
getsentry/sentry-java#6138 · 1 条评论 ·
-
bug needs triage p2
难度 2/5 1-3 小时 新手友好度 78/100
GoogleCloudPlatform/DataflowTemplates#4273 · 1 条评论 ·
-
[Studio][Bug] Bulk-deleting a full page of alert rules steps the page back while more rules remain 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
apache/rocketmq-dashboard#4654 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 76/100