microsoft / microsoft/playwright-java

[Feature]: Implement hasAttribute(String)

オープン
#1,844 コメント 3 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

P3-collecting-feedback
主要言語
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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

issue に示されている Java assertion のエントリポイント PlaywrightAssertions.assertThat から始め、既存の hasAttribute オーバーロードを確認します。locator 属性の不在がどのように表現されるかを確認し、String のみを受け取る要求された形式を追加して、値なしで存在と不在をアサートできるようにします。完了とは、API が示されている .not().hasAttribute("min") の使用方法をサポートすることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
testing-qa
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。