title: How to do sum of the numbers displayed on webpage in selenium webdriver with java
body: <p><strong>My Scenario</strong></p>
  
  <p>"Go to:
    <a href="http://www.americangolf.co.uk/golf-clubs/fairway-woods" rel="nofollow noreferrer">http://www.americangolf.co.uk/golf-clubs/fairway-woods</a>"</p>
  
  <p>Print every link under brand</p>
  
  <p>Every link will have a number in front of it</p>
  
  <p>Find sum of all numbers</p>
  
  <p>Total number of products found is written on the page-"49 Products found"</p>
  
  <p>Verify sum s equal to number of products mentioned</p>
  
  <p><strong>My Code</strong></p>
  
  <pre><code>public class americangolf {
      public static void main(String[] args) 
      {
          WebDriver driver = new FirefoxDriver();
          driver.get("http://www.americangolf.co.uk/golf-clubs/fairway-woods");
          driver.manage().window().maximize();
          driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
          List&lt;WebElement&gt; elem = driver.findElements(By.xpath("//div[@id='secondary']/div[1]/div[3]/div/ul/li/a"));
          for(WebElement li:elem)
          {
              System.out.println(li.getText());
          }
  
          List&lt;WebElement&gt; elem1 = driver.findElements(By.xpath("//div[@id='secondary']/div[1]/div[3]/div/ul/li/a/span[2]"));
  
          for(WebElement li1:elem1)
          {
              System.out.println(li1.getText());
          }
  
          int con= Integer.parseInt(driver.findElement(By.xpath("//div[@id='secondary']/div[1]/div[3]/div/ul/li/a/span[2]")).getText());
  
          for(int i=0;i&lt;elem1.size();i++)
          {
              int sum = i+con;
              System.out.println("Total is:"+sum);
          }
      }
  }
  </code></pre>
  
  <p><strong>Console output</strong></p>
  
  <pre><code>CobraGolf (10)
  CallawayGolf (9)
  TaylorMade (7)
  Ping (6)
  WilsonStaff (4)
  NikeGolf (3)
  Benross (2)
  Titleist (2)
  Wilson (2)
  Fazer (1)
  MizunoGolf (1)
  USKidsGolf (1)
  YONEX (1)
  (10)
  (9)
  (7)
  (6)
  (4)
  (3)
  (2)
  (2)
  (2)
  (1)
  (1)
  (1)
  (1)
  Exception in thread "main" java.lang.NumberFormatException: For input string: "(10)"
  at java.lang.NumberFormatException.forInputString(Unknown Source)
  at java.lang.Integer.parseInt(Unknown Source)
  at java.lang.Integer.parseInt(Unknown Source)
  at module13.americangolf.main(americangolf.java:39)
  </code></pre>
  
  <p>I am getting the above error while doing the sum of all printed numbers. I don't know how to get rid of it. Any solutions to this?</p>