Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.nio.file.Files;
  3. import java.nio.file.Paths;
  4. import org.junit.Before;
  5. import org.junit.Test;
  6. import org.openqa.selenium.By;
  7. import org.openqa.selenium.WebDriver;
  8. import org.openqa.selenium.WebElement;
  9. import org.openqa.selenium.chrome.ChromeDriver;
  10.  
  11. public class InstallServers {
  12.  
  13. WebDriver driver = new ChromeDriver();
  14. private String env_Name = "QA3";
  15. private String BE_Jira_Version;
  16. private String SE_Jira_Version;
  17.  
  18.  
  19. @Before
  20. public void getinfo() throws IOException, InterruptedException {
  21. System.setProperty("webdriver.chrome.driver ", "chromedriver.exe");
  22. driver.get(
  23. "https://jira.poker.ptec/issues/?jql=issuetype%20%3D%20Build%20and%20component%3Dpokerbackend%20and%20fixVersion%3D17.11");
  24. driver.manage().window().maximize();
  25.  
  26. // Login into jira using credentials from txt file
  27. String username = Files.readAllLines(Paths.get("up.txt")).get(0);
  28. String pass = Files.readAllLines(Paths.get("up.txt")).get(1);
  29. driver.findElement(By.id("user-options")).click();
  30. driver.findElement(By.name("os_username")).sendKeys(username);
  31. driver.findElement(By.name("os_password")).sendKeys(pass);
  32. driver.findElement(By.name("login")).click();
  33.  
  34. // getting the latest server and BE version//
  35. WebElement BE = driver.findElement(By.xpath("//td[@class='summary']"));
  36. BE_Jira_Version = BE.getText();
  37. System.out.println("Latest BE version is : " + BE_Jira_Version);
  38.  
  39. // getting latest server_version
  40. driver.findElement(By.id("advanced-search")).clear();
  41. driver.findElement(By.id("advanced-search"))
  42. .sendKeys("issuetype = Build and component=pokergame and fixVersion=17.11");
  43. driver.findElement(By.xpath("//span[text()='Search']")).click();
  44. Thread.sleep(2000);
  45. WebElement SE = driver.findElement(By.xpath("//td[@class='summary']"));
  46. SE_Jira_Version = SE.getText();
  47. System.out.println("Latest server version is : " + SE_Jira_Version);
  48.  
  49. // getting current version of server and BE from poker_apps page
  50. driver.get("http://bg-hs/poker-versions/");
  51. WebElement BE_apps = driver.findElement(By.xpath("//td[@site='QA3' and @field='poker_backend']"));
  52. String BE_apps_Version = BE_apps.getText();
  53. System.out.println("Current BE version is : " + BE_apps_Version);
  54. WebElement SE_apps = driver.findElement(By.xpath("//td[@site='QA3' and @field='poker_servers']"));
  55. String SE_apps_Version = SE_apps.getText();
  56. System.out.println("Current Server version is : " + SE_apps_Version);
  57.  
  58. // All required versions are got
  59. }
  60.  
  61. public void setBE_version(String BE_Jira_Version) {
  62. this.BE_Jira_Version = BE_Jira_Version;
  63. }
  64.  
  65. public void setSE_version(String SE_Jira_Version) {
  66. this.SE_Jira_Version = SE_Jira_Version;
  67. }
  68. @Test
  69. public void Install() throws IOException {
  70. String username = Files.readAllLines(Paths.get("up.txt")).get(0);
  71. String pass = Files.readAllLines(Paths.get("up.txt")).get(1);
  72. driver.get("http://bamboo.poker.ptec/allPlans.action");
  73. driver.findElement(By.id("login")).click();
  74. driver.findElement(By.name("os_username")).sendKeys(username);
  75. driver.findElement(By.name("os_password")).sendKeys(pass);
  76. driver.findElement(By.id("loginForm_save")).click();
  77. driver.findElement(By.id("viewBuild:POKDEP-" + env_Name)).click();
  78. driver.findElement(By.xpath("//button[contains(., 'Action')]")).click();
  79. driver.findElement(By.id("editBuild:POKDEP-" + env_Name)).click();
  80. driver.findElement(By.id("variables_POKDEP-" + env_Name)).click();
  81. driver.findElement(By.xpath("//input[@value= 'BE_VERSION']")).click();
  82. WebElement webElement = driver.findElement(By.xpath("//input[@value= 'BE_VERSION']"));
  83. // Will use BE and SE jira version latest for populating the bamboo version fields
  84. System.out.println(BE_Jira_Version);
  85. System.out.println(SE_Jira_Version);
  86.  
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement