I want to verify from this website: https://demo.nopcommerce.com/. There are 4 products shown with the Euro symbol by using for loop.


    List <WebElement> productcurrency = driver.findelEments(By.xpath(“span[text()=\”€\”]”));

system.out.println(“4”+ productcurrency.size());
  • 1
    Post your current code. What error are you getting / issue facing?
    – Prome
    Commented Jan 17, 2023 at 10:21
  • List <WebElement> productcurrency =driver.findelEments(By.xpath(“span[text()=\”€\”]”)); system.out.println(“4”+ productcurrency.size());
    – Esraa Emad
    Commented Jan 17, 2023 at 14:11
  • And what error are you getting?
    – Prome
    Commented Jan 19, 2023 at 9:11

1 Answer 1


I do not see any products in your application with euro(€) symbol. However I see there are 4 products with dollar($) symbol. Assuming this is what you want, try the below code:

List<WebElement> productcurrency  = driver.findElements(By.xpath("//span[contains(text(),'$')]"));
System.out.println("productcurrency  size is: " + productcurrency .size());

Console output:

productcurrency  size is: 4

XPath expression explanation:

//span[contains(text(),'$')] - This relative xpath expression will search the entire DOM for tag span which contains text $

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.