Module 15 , get the player name who scrored maximum | Selenium Forum
M
Posted on 22/08/2015
Hi Team,
How to get the player name who scored maximum.

Here in below code i am able to get individual score and converted into integer from string.
Now i need to compare the each score and get the maximum score . In order to do so i hope i need to pass the integer to Array. But i am not sure how to do so.Pls help me



driver.get("http://www.cricbuzz.com/live-cricket-scorecard/14875/sl-vs-ind-2nd-test-india-tour-of-sri-lanka-2015---cricbuzz-cup");
List<WebElement> ls=driver.findElements(By.xpath("//*[@id='innings_1']/div[1]/div/table/tbody/tr/td[3]"));
int sum=0;
System.out.println(ls.size());
for(int i=0;i<ls.size();i++)
{
int n=Integer.parseInt(ls.get(i).getText());

sum=sum+n;
//System.out.println(ls.get(i).getText());

}System.out.println(sum);
driver.quit();

}

M
Replied on 22/08/2015

You are calculating sum here
We need to get the name of player with max runs

for that make a variable like

int maxScore;

This variable in loop should equate the highest score - You need to write logic for that Responsive image

Try Responsive image