Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

253
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda