I wan to use multi dimensional array in java. instead of using arrayList. I am trying to rework on my code. I automate my app to select a game, but need to store in every row of data in string array....so i can loop through each row by row to check the game date, hometeam name and away team name whether matching or not ?
WebElement listView = AppSession.findElementByAccessibilityId("ListView1");
List<WebElement> row = listView.findElements(By.tagName("./*[contains(@LocalizedControlType, 'item')]"));
ArrayList<ArrayList<String>> outerList = new ArrayList<ArrayList<String>>();
for (int a = 0; a < row.size(); a++) {
ArrayList<String> innerList = new ArrayList<String>();
List<WebElement> column = row.get(a).findElements(By.tagName("./*[contains(@LocalizedControlType, 'text')]"));
if(!column.isEmpty()){
for (int j = 0; j < column.size(); j++)
{
innerList.add(column.get(j).getAttribute("Name"));
}
outerList.add(innerList);
}
}
System.out.println(outerList);
for (int i = 0; i < outerList.size(); i++) {
if ((outerList.get(i).contains(game_date)) && (outerList.get(i).contains(home_team_name)) && (outerList.get(i).contains(away_team_name))) {
WebElement line_up1 = AppSession.findElementByName(game_date);
line_up1.click();
}
}
this is how my gui app looks like for game selection...
Game date home team away team 06/29/2018 07:00:00 PM Ball Hogs Ball Hogs Tri-State Tri-State 06/29/2018 08:00:00 PM Power Ghost BALLERS 06/29/2018 07:00:00 PM Killer 3's 3's Company
outer list like this ::
[[06/29/2018 07:00:00 PM ,Ball Hogs Ball Hogs ,Tri-State Tri-State],[06/29/2018 08:00:00 PM, Power, Ghost BALLERS],[06/29/2018 07:00:00 PM, Killer 3's, 3's Company]]
How to use multi dimensinal array instead of using array list in java
WebElement listView = AppSession.findElementByAccessibilityId("ListView1");
List<WebElement> row =listView.findElements(By.tagName("./*[contains(@LocalizedControlType, 'item')]"));
String[][] records = new String[row.size()][5];//11
System.out.println(row.size());//11
for(int a = 0; a < row.size(); a++)
{
List<WebElement> column = row.get(a).findElements(By.tagName("./*[contains(@LocalizedControlType, 'text')]"));
if(!column.isEmpty()){
for(int j = 0; j < 5; j++){
records[a][j] = column.get(j).getAttribute("Name");
System.out.println(records[a][j]);
}
}
}
System.out.println(records.length); //row count 10 System.out.println(records[0].length); //column count 5
for(int lineNum=5;lineNum<records.length;lineNum++) {
for(int colNum=0;colNum<5;colNum++)
{
if ((records[lineNum][colNum].contains(game_date)) && (records[lineNum][colNum].contains(home_team_name)) && (records[lineNum][colNum].contains(away_team_name)))
{
WebElement line_up1 = AppSession.findElementByName(game_date);
line_up1.click();
AppSession.findElementByAccessibilityId("btnDelete").click();
AppSession.findElementByName("Yes").click();
WebDriverWait wait1 = new WebDriverWait(AppSession, 5);
wait1.until(ExpectedConditions.visibilityOfElementLocated(By.name("OK")));
AppSession.findElementByAccessibilityId("2").click();
line_up1.click();
AppSession.findElementByAccessibilityId("btnOk").click();
}
}
}
output
06/22/2018 09:00:00 PM
Indiana Fever
Seattle Storm
WNBA
5
07/22/2018 02:00:00 PM
Seattle Storm
Atlanta Dream
WNBA
5
08/01/2018 09:00:00 PM
Phoenix Mercury
Las Vegas Aces
WNBA
5
it is click on eclipse top most left restore view.. it is not click on the respective game..why ?
this is the data i am getting,I have data from backend. like gamedate, hometeamname and awayteam name.. i am stored in 3 variables. but how to do check with gamedate, hometeam, awayteam. whether if it matches then i need to select ?