Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #players names :: positions
- Happ = CF
- Bryant = 3B
- Rizzo = 1B
- Contreras = C
- Schwarber = LF
- Russell = SS
- Heyward = RF
- Baez = 2B
- public void awayTeamHitters() {
- try
- {
- String[] players = new String[]
- {
- "Happ, Ian#",
- "Bryant, Kris",
- "Rizzo, Anthony*",
- "Contreras, Willson",
- "Schwarber, Kyle*",
- "Russell, Addison",
- "Heyward, Jason*",
- "Baez, Javier"
- };
- String[] positions=new String[]
- {
- "CF",
- "3B",
- "1B",
- "C",
- "LF",
- "SS",
- "RF",
- "2B"
- };
- List<String> playersInList = Arrays.asList(players);
- List<String> positionsInlist=Arrays.asList(positions);
- //combine player table 1 and 2
- player_table2.addAll(player_table1);
- List<String> player_table3=new ArrayList<String>();
- player_table3.addAll(player_table2);
- System.out.println(player_table3); //it will print the 25 player names
- int p=player_table3.size();
- System.out.println(p); //it will print the size 25
- for(int i=0;i<p;i++)
- {
- for(int j=0;j<=i+1;j++)
- {
- if(!playersInList.contains(player_table3)) {
- //player selection for doubleclick action
- Actions act = new Actions(driver);
- act.doubleClick().build().perform();
- break;
- }
- //select each player position for single click
- WebElement pos= driver.findElementById("PlayerPositions");
- List<WebElement> col=pos.findElements(By.xpath("./*[contains(@LocalizedControlType, 'button')]"));
- if(positionsInlist.contains(col.get(i))) {
- col.get(i).click();
- }
- }
- }
- }
- catch (Exception e) {
- System.out.println(e);
- }
- }
- {
- String[] players = new String[]{
- "Player 1",
- "Player 2",
- "Player 3",
- // ...
- "Player N"
- };
- try {
- List<String> playersInList = Arrays.asList(players);
- WebElement table = driver.findElement(By.xpath(".//*[@AutomationId='lsvAwayTeamHitters1']"));
- List<WebElement> rows = table.findElements(By.xpath("./*[contains(@LocalizedControlType, 'item')]"));
- for (WebElement row : rows) {
- List<WebElement> cols = row.findElements(By.xpath("./*[contains(@LocalizedControlType, 'text')]"));
- for (WebElement col : cols) {
- String celtext = col.getAttribute("Name");
- if (playersInList.contains(celtext)) {
- // process your player here
- }
- }
- }
- ArrayList<String> inputList = new ArrayList<String>();
- // ... Remaining code
- }
- }
- for(int j=3;j<=col.size();j++) {
- String celtext = col.get(j).getAttribute("Name");
- System.out.println(celtext);
- }
Add Comment
Please, Sign In to add comment