-1

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.

4

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. – Muhammad Atif Muneeb Alrai May 22 at 8:48
  • Was running if(price.equals("xxxxx") problematic? – João Farias May 22 at 9:02
  • I am trying as if (Price >= some vale here) – Muhammad Atif Muneeb Alrai May 22 at 10:35
  • 1
    then convert your string into integer like this - int result = Integer.parseInt(price); – Upkar Singh May 22 at 11:24
1

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:

Integer.valueOf(price);

If you expect floats too, you can do :

Float.parseFloat(price);

HTH!

  • 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 ? – Muhammad Atif Muneeb Alrai May 23 at 6:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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