I am testing a website and I need to perform some action on the basis of Price. It is showing price in Remaining Budget. I want to check the remaining budget and then on the basis of it want to perform action. enter image description here

You can see in pic about it. Kindly share your experience about this.

2 Answers 2


Yes, you can get values in form of String after that you can use them as you want.
like this -

String price = driver.findElement(By.xpath("your-xpth-of-selected-value")).getText();  

Now this string value you can use as you need.

  • I have tried your solution and its working for me. But one things that its storing value in string and I want to use that value in if condition How I can use it. May 22, 2019 at 8:48
  • Was running if(price.equals("xxxxx") problematic? May 22, 2019 at 9:02
  • I am trying as if (Price >= some vale here) May 22, 2019 at 10:35
  • 1
    then convert your string into integer like this - int result = Integer.parseInt(price); May 22, 2019 at 11:24

As suggested in above comment by Joao, you can get the text by

String price = driver.findElement(By.xpath("your-xpth-of-selected-value")).getText();  

If you expect only integers in price, then you can do:


If you expect floats too, you can do :



  • Now the issue is that its showing out put as " $24.00 ". I have to use this value in If condition or in For loop as the value is a mix of int, float and string how I can use it ? May 23, 2019 at 6:30

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.