Guest User

Untitled

a guest
May 25th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. #players names :: positions
  2. Happ = CF
  3. Bryant = 3B
  4. Rizzo = 1B
  5. Contreras = C
  6. Schwarber = LF
  7. Russell = SS
  8. Heyward = RF
  9. Baez = 2B
  10.  
  11. public void awayTeamHitters() {
  12.  
  13.  
  14. try
  15. {
  16. String[] players = new String[]
  17. {
  18. "Happ, Ian#",
  19. "Bryant, Kris",
  20. "Rizzo, Anthony*",
  21. "Contreras, Willson",
  22. "Schwarber, Kyle*",
  23. "Russell, Addison",
  24. "Heyward, Jason*",
  25. "Baez, Javier"
  26. };
  27. String[] positions=new String[]
  28. {
  29. "CF",
  30. "3B",
  31. "1B",
  32. "C",
  33. "LF",
  34. "SS",
  35. "RF",
  36. "2B"
  37. };
  38.  
  39.  
  40. List<String> playersInList = Arrays.asList(players);
  41. List<String> positionsInlist=Arrays.asList(positions);
  42. //combine player table 1 and 2
  43. player_table2.addAll(player_table1);
  44. List<String> player_table3=new ArrayList<String>();
  45. player_table3.addAll(player_table2);
  46. System.out.println(player_table3); //it will print the 25 player names
  47. int p=player_table3.size();
  48. System.out.println(p); //it will print the size 25
  49. for(int i=0;i<p;i++)
  50. {
  51. for(int j=0;j<=i+1;j++)
  52. {
  53. if(!playersInList.contains(player_table3)) {
  54. //player selection for doubleclick action
  55. Actions act = new Actions(driver);
  56. act.doubleClick().build().perform();
  57. break;
  58. }
  59. //select each player position for single click
  60. WebElement pos= driver.findElementById("PlayerPositions");
  61. List<WebElement> col=pos.findElements(By.xpath("./*[contains(@LocalizedControlType, 'button')]"));
  62. if(positionsInlist.contains(col.get(i))) {
  63.  
  64.  
  65. col.get(i).click();
  66.  
  67. }
  68. }
  69.  
  70. }
  71. }
  72. catch (Exception e) {
  73. System.out.println(e);
  74. }
  75. }
  76.  
  77. {
  78. String[] players = new String[]{
  79. "Player 1",
  80. "Player 2",
  81. "Player 3",
  82. // ...
  83. "Player N"
  84. };
  85.  
  86. try {
  87. List<String> playersInList = Arrays.asList(players);
  88. WebElement table = driver.findElement(By.xpath(".//*[@AutomationId='lsvAwayTeamHitters1']"));
  89. List<WebElement> rows = table.findElements(By.xpath("./*[contains(@LocalizedControlType, 'item')]"));
  90. for (WebElement row : rows) {
  91. List<WebElement> cols = row.findElements(By.xpath("./*[contains(@LocalizedControlType, 'text')]"));
  92. for (WebElement col : cols) {
  93. String celtext = col.getAttribute("Name");
  94. if (playersInList.contains(celtext)) {
  95. // process your player here
  96. }
  97.  
  98. }
  99. }
  100. ArrayList<String> inputList = new ArrayList<String>();
  101. // ... Remaining code
  102. }
  103. }
  104.  
  105. for(int j=3;j<=col.size();j++) {
  106. String celtext = col.get(j).getAttribute("Name");
  107. System.out.println(celtext);
  108. }
Add Comment
Please, Sign In to add comment