How to do sum of displayed numbers on webpage in module 13
How to do sum of displayed numbers on webpage in module 13
M
Posted on 02/02/2017
My Scenario
"Go to: http://www.americangolf.co.uk/golf-clubs/fairway-woods" Print every link under brand Every link will have a number in front of it Find sum of all numbers Total number of products found is written on the page-"49 Products found" Verify sum s equal to number of products mentioned
int con= Integer.parseInt(driver.findElement(By.xpath("//div[@id='secondary']/div[1]/div[3]/div/ul/li/a/span[2]")).getText().replace("(","").replace(")",""));
for(int i=0;i<=elem1.size();i++) {
int sum = i+con; System.out.println("Total is:"+sum); } } }
but i am not able to do sum of numbers instead of adding numbers it is printing like below
Total is:10 Total is:11 Total is:12 Total is:13 Total is:14 Total is:15 Total is:16 Total is:17 Total is:18 Total is:19 Total is:20
please tell me where i am going wrong.
M
Replied on 02/02/2017
do this [quote:36g2xm00] int sum=0; for(int i=0;i<=elem1.size();i++) {
sum = sum +con; System.out.println("Total is:"+sum); } [/quote:36g2xm00]