microsoft / microsoft/playwright-java

[Feature]: Implement hasAttribute(String)

Abierto
#1,844 3 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

P3-collecting-feedback
Lenguaje dominante
Java
Estrellas
1.6k
Forks
298
Merge medio
3 d 2 h
PR fusionados (30 d)
14

Descripción

🚀 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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza en el punto de entrada de aserciones de Java mostrado en el issue, PlaywrightAssertions.assertThat, e inspecciona las sobrecargas existentes de hasAttribute. Confirma cómo se representa la ausencia de un atributo del locator y añade la forma solicitada que solo recibe String, de modo que se puedan comprobar la presencia y la ausencia sin un valor; se considera terminado cuando la API admite el uso mostrado de .not().hasAttribute("min").

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
java
Área
testing-qa
Tipo de issue
Nueva funcionalidad
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.