WebElement NetReceivable=wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("html/body/form/table[2]/tbody/tr[2]/td/table[2]/tbody/tr/td/table/tbody/tr[19]/td[2]")));

String NetReceivableamt=NetReceivable.getText();
System.out.println("NetReceivable amount::"+NetReceivableamt); //working fine till here

Double NetReceivableamtint = Double.parseDouble(NetReceivableamt);

** below error getting while parsing it to double**

java.lang.NumberFormatException: For input string: "196,003.20"
                            at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
                            at sun.misc.FloatingDecimal.parseDouble(Unknown Source)
                            at java.lang.Double.parseDouble(Unknown Source)
                            at com.Test.Loan_Termination.Loan_Processing(Loan_Termination.java:431)
                            at com.Test.App.main(App.java:96)

Your number is not in the correct double format. Use the DecimalFormat to parse it:

    DecimalFormat df = new DecimalFormat();
    DecimalFormatSymbols symbols = new DecimalFormatSymbols();
    Double NetReceivableamtint = df.parse(NetReceivableamt);

Also take care of the Java naming convention. Variable names should start with lower case caracters

| improve this answer | |
  • 2
    Great answer. I would also add that using Thread.sleep() is a very bad practice and it should be avoided – Ilya Khadykin Jan 4 '18 at 14:18

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