I am working in windows application automation testing. I want to perform a multiple task like to select a player name and its position. My application is a baseball reporter software. so, I'm automating to select 8 players from the table. I keep the player names and their positions in excel sheet. my application manual working process for selecting a line ups is to double click a player and then another box comes to select a position of those player. my issue is that I am double clicking on wrong element....how I perform double click on that exact player ?
this is the code..
public class LineUps {
private WiniumDriver driver;
public LineUps(WiniumDriver driver) throws MalformedURLException, InterruptedException {
this.driver=driver;
}
public void away_team_lineups_excel()
{
try {
driver.findElementById("lblAwayTeamHittersAll").click();
WebElement away_players_list1 = driver.findElementById("lsvAwayTeamHitters1");
WebElement away_players_list2 = driver.findElement(By.id("lsvAwayTeamHitters2"));
List<WebElement> away_team_players_lineups1 = away_players_list1.findElements(By.xpath("./*[contains(@LocalizedControlType, 'item')]"));
List<WebElement> away_team_players_lineups2 = away_players_list2.findElements(By.xpath("./*[contains(@LocalizedControlType, 'item')]"));
List<String> away_players1 = new ArrayList<String>();
for(int i=0;i<away_team_players_lineups1.size();i++)
{
List<WebElement> away_team_players_names = away_team_players_lineups1.get(i).findElements(By.xpath("./*[contains(@LocalizedControlType, 'text')]"));
for(int j=3;j<away_team_players_names.size();j++)
{
String celtext = away_team_players_names.get(j).getAttribute("Name");
// System.out.println(celtext);
away_players1.add(celtext);
}
}
List<String> away_players2 = new ArrayList<String>();
for(int j=0;j<away_team_players_lineups2.size();j++)
{
List<WebElement> away_team_players_names2 = away_team_players_lineups2.get(j).findElements(By.xpath("./*[contains(@LocalizedControlType, 'text')]"));
for(int k=3;k<away_team_players_names2.size();k++)
{
String celtext = away_team_players_names2.get(k).getAttribute("Name");
// System.out.println(celtext);
away_players2.add(celtext);
}
}
away_players2.addAll(away_players1);
List<String> away_players3 = new ArrayList<String>();
away_players3.addAll(away_players2);
System.out.println(away_players3);
System.out.println(away_players3.size());
System.err.close();
System.setErr(System.out);
File f= new File("player.xlsx");
FileInputStream fs= new FileInputStream(f);
XSSFWorkbook wb= new XSSFWorkbook(fs);
XSSFSheet bb_players= wb.getSheetAt(0);
int rowcount= bb_players.getLastRowNum();
System.out.println("Total rows is: " +rowcount);
Actions act= new Actions(driver);
for(int i=1; i<=rowcount; i++)
{
String player = bb_players.getRow(i).getCell(0).getStringCellValue();
String position = bb_players.getRow(i).getCell(1).getStringCellValue();
for(int j=0; j<away_players3.size(); j++)
{
String away_total_players= away_players3.get(j);
if(!away_total_players.equals(player))
{
break;
}
else
{
WebElement line_up1=driver.findElementByLinkText(player);
System.out.println(line_up1);
act.moveToElement(line_up1).doubleClick().build().perform();;
}
WebElement away_players_pos = driver.findElementById("PlayerPositions");
List<WebElement> player_pos = away_players_pos.findElements(By.xpath("./*[contains(@ControlType,'Button')]"));
if(position.equals(player_pos.get(i)))
{
player_pos.get(i).click();
}
}
}
}
catch (Exception e)
{
System.out.println(e);
}
}
}
how to double click on the particular name webelement ?
Firstly I want try whether I can able to select one player and its position, then I can add loops to select multiple players... Inside action class my element must be wrong, that's why double click is not working a single player. how I write the matching webelement on inside action class.... How to perform double click on the first player "Happ Ian" and select its position "CF"
anybody please help me