Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.IOException;
- import java.nio.file.Files;
- import java.nio.file.Paths;
- import org.junit.Before;
- import org.junit.Test;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.chrome.ChromeDriver;
- public class InstallServers {
- WebDriver driver = new ChromeDriver();
- private String env_Name = "QA3";
- private String BE_Jira_Version;
- private String SE_Jira_Version;
- @Before
- public void getinfo() throws IOException, InterruptedException {
- System.setProperty("webdriver.chrome.driver ", "chromedriver.exe");
- driver.get(
- "https://jira.poker.ptec/issues/?jql=issuetype%20%3D%20Build%20and%20component%3Dpokerbackend%20and%20fixVersion%3D17.11");
- driver.manage().window().maximize();
- // Login into jira using credentials from txt file
- String username = Files.readAllLines(Paths.get("up.txt")).get(0);
- String pass = Files.readAllLines(Paths.get("up.txt")).get(1);
- driver.findElement(By.id("user-options")).click();
- driver.findElement(By.name("os_username")).sendKeys(username);
- driver.findElement(By.name("os_password")).sendKeys(pass);
- driver.findElement(By.name("login")).click();
- // getting the latest server and BE version//
- WebElement BE = driver.findElement(By.xpath("//td[@class='summary']"));
- BE_Jira_Version = BE.getText();
- System.out.println("Latest BE version is : " + BE_Jira_Version);
- // getting latest server_version
- driver.findElement(By.id("advanced-search")).clear();
- driver.findElement(By.id("advanced-search"))
- .sendKeys("issuetype = Build and component=pokergame and fixVersion=17.11");
- driver.findElement(By.xpath("//span[text()='Search']")).click();
- Thread.sleep(2000);
- WebElement SE = driver.findElement(By.xpath("//td[@class='summary']"));
- SE_Jira_Version = SE.getText();
- System.out.println("Latest server version is : " + SE_Jira_Version);
- // getting current version of server and BE from poker_apps page
- driver.get("http://bg-hs/poker-versions/");
- WebElement BE_apps = driver.findElement(By.xpath("//td[@site='QA3' and @field='poker_backend']"));
- String BE_apps_Version = BE_apps.getText();
- System.out.println("Current BE version is : " + BE_apps_Version);
- WebElement SE_apps = driver.findElement(By.xpath("//td[@site='QA3' and @field='poker_servers']"));
- String SE_apps_Version = SE_apps.getText();
- System.out.println("Current Server version is : " + SE_apps_Version);
- // All required versions are got
- }
- public void setBE_version(String BE_Jira_Version) {
- this.BE_Jira_Version = BE_Jira_Version;
- }
- public void setSE_version(String SE_Jira_Version) {
- this.SE_Jira_Version = SE_Jira_Version;
- }
- @Test
- public void Install() throws IOException {
- String username = Files.readAllLines(Paths.get("up.txt")).get(0);
- String pass = Files.readAllLines(Paths.get("up.txt")).get(1);
- driver.get("http://bamboo.poker.ptec/allPlans.action");
- driver.findElement(By.id("login")).click();
- driver.findElement(By.name("os_username")).sendKeys(username);
- driver.findElement(By.name("os_password")).sendKeys(pass);
- driver.findElement(By.id("loginForm_save")).click();
- driver.findElement(By.id("viewBuild:POKDEP-" + env_Name)).click();
- driver.findElement(By.xpath("//button[contains(., 'Action')]")).click();
- driver.findElement(By.id("editBuild:POKDEP-" + env_Name)).click();
- driver.findElement(By.id("variables_POKDEP-" + env_Name)).click();
- driver.findElement(By.xpath("//input[@value= 'BE_VERSION']")).click();
- WebElement webElement = driver.findElement(By.xpath("//input[@value= 'BE_VERSION']"));
- // Will use BE and SE jira version latest for populating the bamboo version fields
- System.out.println(BE_Jira_Version);
- System.out.println(SE_Jira_Version);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement