Advertisement
Guest User

Untitled

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