• Home

  • Courses

    • Run Java Selenium Tests in Azure Devops
    • Interviewing for Testing Positions
  • For Business

  • Trainings

    • Beginner Selenium (May 2018)
    • Advanced Selenium (Feb 2019)
  • Teacher

  • Bootcamp Info

  • Forum

  • Blog

  • Meetups

    • Test Automation for Responsive Site
    • All about Locators in Selenium Projects
  • More..

    • FAQ
    • Cheat Sheets
    • Presentations
  • More...

    Use tab to navigate through the menu items.
    To see this working, head to your live site.
    • Categories
    • All Posts
    • My Posts
    bogelena5
    May 31, 2018

    NumberFormatException

    in Selenium Questions

    private int resultsCount() {

    WebElement label = findVisibleElement(TOTAL_COUNT_ID);

    String text = label.getText();

    int count = Integer.parseInt(text);

    return count;

    }

    When hover mouse over parseInt you can see that:

    int java.lang.Integer.parseInt(String arg0) throws NumberFormatException


    It might happen if the string does not contain a parsable integer.

    But the string in this case is 37,183 , means parsable.

    What is wrong then?


    2 comments
    0
    2 Comments

    Share Your ThoughtsSign up to leave a comment.

    bogelena5
    May 31, 2018

    Thank you

    Like

    alexsiminiuc3
    May 31, 2018

    remove the comma and it will work:


    private int resultsCount() {
       WebElement label = findVisibleElement(TOTAL_COUNT_ID);
       String text = label.getText();
       text = text.replace(",", "");
       int count = Integer.parseInt(text);
       return count;
    }

    Like
    2 comments

    © 2021 Vancouver Selenium WebDriver Automation Training