How to create a 'log in to JIRA' test case using Selenium Java Webdriver/WebAPI?

Here is the issue. We recorded a test case to log in to JIRA using Selenium IDE and it replayed successfully. But when we converted the code in to JAVA/JUnit, it didn't execute. It gave element not found run time error.

The code:


package testlogin;

import java.util.concurrent.TimeUnit;

import org.junit.*;

import static org.junit.Assert.*;

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Test1 {
private WebDriver driver;
private String baseUrl;

private final StringBuffer verificationErrors = new StringBuffer();

public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "http://jiratest/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

public void testUntitled2() throws Exception {
driver.get(baseUrl + "");
for (int second = 0;; second++) {
if (second >= 6) fail("timeout");
try { if (driver.findElement("usernamelabel")).isDisplayed()) break; } catch (Exception e) {}


public void tearDown() throws Exception {
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {


Main method class: 

package testlogin;

import org.junit.runner.JUnitCore;

public class TestLogin {

* @param args the command line arguments
* @throws java.lang.Exception
public static void main(String[] args) throws Exception {



2 answers

I got the same error, did you get this case to work?

Late to the party, but if you still have a problem with this, try the following:


Replace: driver.findElement("login")).click();

With: driver.findElement("login-form-password")).submit();

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,043 views 4 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you