Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

254
Vistas
How to check that all items in the list contains any character from string
List<WebElement> elements = driver.findElements(By.className("price"));
        for (WebElement element : elements) {
            System.out.println(element.getText());
    }


        String currency = driver.findElement(By.cssSelector("#_desktop_currency_selector > div > span.expand-more._gray-darker.hidden-sm-down")).getText();
        System.out.println(currency);

I have list that contains: 22,33 $ 44,22 $ 22,11 $ ...

And a string that contains: USD $

My test needs to check that the currency type from the dropdown located in the site header matches the currency type char in all of the displayed items.

If all elements from the list contain any symbol from currency settings (for example $) - test passed, else failed

Tried to use assert that contains but still can't get how to make it work... I would be grateful for the help

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

First, I'd extract the currency symbol (assumption: it's a single character at the end of the currency string):

String currencySymbol = currency.substring(currency.length() - 2);

Then, I'd go over all the elements and check they contain it:

for (WebElement element : elements) {
    // You should probably also add a user-friendly message here
    assertTrue(element.getText().endsWith(currencySymbol));
}
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda