microsoft / microsoft/playwright-java
[Feature]: Implement hasAttribute(String)
Nessuno ha ancora preso questa issue.
- Lingua principale
- Java
- Stelle
- 1.6k
- Fork
- 298
- Merge medio
- 3g 2h
- PR unite (30g)
- 14
Descrizione
🚀 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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dal punto di ingresso delle asserzioni Java mostrato nell’issue, PlaywrightAssertions.assertThat, e ispeziona gli overload esistenti di hasAttribute. Conferma come viene rappresentata l’assenza di un attributo del locator e aggiungi la forma richiesta che accetta solo String, in modo che la presenza e l’assenza possano essere verificate senza un valore; il lavoro è completo quando l’API supporta l’uso mostrato di .not().hasAttribute("min").
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java
- Ambito
- testing-qa
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100