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();
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "http://jiratest/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testUntitled2() throws Exception {
driver.get(baseUrl + "");
for (int second = 0;; second++) {
if (second >= 6) fail("timeout");
try { if (driver.findElement(By.id("usernamelabel")).isDisplayed()) break; } catch (Exception e) {}
Thread.sleep(10);
}
driver.findElement(By.id("login-form-username")).click();
driver.findElement(By.id("login-form-username")).clear();
driver.findElement(By.id("login-form-username")).sendKeys("hasblk");
driver.findElement(By.id("login-form-password")).click();
driver.findElement(By.id("login-form-password")).clear();
driver.findElement(By.id("login-form-password")).sendKeys("hasblk");
driver.findElement(By.id("login")).click();
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(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 {
JUnitCore.main("testlogin.Test1");
}
}
I got the same error, did you get this case to work?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.