Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

248
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!