Tuesday, October 18, 2016

Sample Selenium test for JIRA

Selenium Basic code for login in to JIRA


Below code will be login to our JIRA System and validate the Title of the User logged in Page

==============================================
package JIRALogin;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.annotations.AfterTest;

public class JIRALoginLogout
{
WebDriver driver;
@Test
public void LoginToJira(String username, String password ) throws InterruptedException
{
driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("http://ABCD.COM"); // >> replace the actual JIRA URL

driver.findElement(By.id("login-form-username")).sendKeys(username);
driver.findElement(By.id("login-form-password")).sendKeys(password);
driver.findElement(By.xpath(".//*[@id='login']")).click();

Thread.sleep(5000);


Assert.assertTrue(driver.getTitle().contains("Resource"),"User naot able to Login to JIRA system");

System.out.println("User can able to Login Successfully in to JIRA System");
}

@AfterTest
public void tearDown()
{
driver.quit();
}
public Object[][] passData()
{
Object[][] data=new Object[3][2];

data[0][0]="abcd"; //>> Replace with actual Username
data[0][1]="xxxx"; // >> Replace with actual password
return data;
}
}

No comments:

Post a Comment