microsoft / microsoft/playwright-java
[Feature]: Implement hasAttribute(String)
まだ誰も着手していません。
- 主要言語
- Java
- スター
- 1.6k
- フォーク
- 298
- 平均マージ
- 3日 2時間
- マージ済み PR(30日)
- 14
説明
🚀 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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
issue に示されている Java assertion のエントリポイント PlaywrightAssertions.assertThat から始め、既存の hasAttribute オーバーロードを確認します。locator 属性の不在がどのように表現されるかを確認し、String のみを受け取る要求された形式を追加して、値なしで存在と不在をアサートできるようにします。完了とは、API が示されている .not().hasAttribute("min") の使用方法をサポートすることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java
- 領域
- testing-qa
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100