Not printing lowest price value using selenium webdriver and java language on Makemytrip application

here I am able to print the all prices, but problem in number format.

//print lowest price
    List<String> pricevalue = new ArrayList<String>();
List<WebElement> actualprice= driver.findElements(By.xpath("//span[contains(@class, 'actual-price')]"));
    for(int i=0;i<actualprice.size();i++){

    int size1 = pricevalue.size();
    long [] arr = new long [size1];
    for(int i=0; i<size1; i++) {
        String newStr = pricevalue.get(i).replace("₹", "").replace(",", "").replaceAll("\\s", "");
        try {
            arr[i] = Long.parseLong(newStr);
    catch (NumberFormatException e){
        System.out.println("not a number");

    long minValue = arr[0];
    for(int i=1;i<arr.length;i++){
        if(arr[i] < minValue){
            minValue = arr[i];
    System.out.println("lowest price value is "+minValue);

output getting :


not a number

not a number

1 Answer 1


First print getText() value before replace,

GetText retrieves only those text which is rendered and displayed in UI. Other Text will be extracted as blank. You can use textCOntent to retrive text without considering the render status.

so you have so many blank values that you are trying to parse.

so use below code instead to get text:

  • 1
    Thanks its now working fine
    – Antony
    Oct 24, 2020 at 12:11

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.