New to Selenium and automation.
First of all my tests are running fine within Eclipse when I run those with Junit. But if I kick off the test via Jenkins or CLI I get the result: Total tests run: 0, Failures: 0, Skips: 0
Now I could be getting the structure of the test wrong or I maybe doing something totally wrong. I have looked all over and all the solutions online don't seem to fix my issue.
My test is just a simple login test that is all.
I think I may have the frameworks mixed up or using them together in the wrong way. I am using Testng to kick off my selenium tests I think. Again I put my hands up here and admit I'm new to this so I'm hoping someone can tell me where I'm going wrong. I do notice in my actual selenium test file I'm not using any Testng functions or anything but just the selenium web driver. I have listed my code files below and results I'm getting from testing.
Again apologies if I'm missing a simple step or I'm trying something that isn't possible, I just need some help or a point in the right direction from an expert. Thanks for any help in advance.
test
I have remove actual URL and creds for security reasons.
package testing;
import static org.junit.Assert.fail;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
public class login {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
System.setProperty("webdriver.gecko.driver","C:\\gecko\\geckodriver.exe");
driver = new FirefoxDriver();
baseUrl = "";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testLogin() throws Exception {
driver.get(baseUrl + "");
driver.findElement(By.id("email")).clear();
d
river.findElement(By.id("email")).sendKeys("");
driver.findElement(By.id("password")).clear();
driver.findElement(By.id("password")).sendKeys("");
driver.findElement(By.xpath("//input[@value='Login »']")).click();
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
private boolean isAlertPresent() {
try {
driver.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
}
private String closeAlertAndGetItsText() {
try {
Alert alert = driver.switchTo().alert();
String alertText = alert.getText();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alertText;
} finally {
acceptNextAlert = true;
}
}
}
testng.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Sample Suite">
<test name="Learning Jenkins">
<classes>
<class name="testing.login"></class>
</classes>
</test>
</suite>
Results from CLI or Jenkins Test
[TestNG] Running:
C:\Users\keating99\workspace\FdimTests\testng.xml
===============================================
Sample Suite
Total tests run: 0, Failures: 0, Skips: 0
===============================================
Finished: SUCCESS
Again I do realize I'm not using any Testng in my actual test, but the aim of my test is to just kick off selenium to run the test. Maybe I'm going about it in the wrong way.
The selenium test is valid and I can launch from within Eclipse.
Thanks for any help in advance!