Reputation: 195
I'm new to Jenkins. My basic Jenkins configuration did work earlier from command line nicely but since I did report configuration the TESTS aren't initiating anymore from Jenkins. I installed 'Email Extension' and 'Email Extension Template' plugins that started to cause the problem (explained) below but I now have removed them but the problem persists.
I see the spinning wheel under the last line (below) and nothing happens.
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running cucumber.CucumberRunner
Starting ChromeDriver 2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e) on port 8791
Only local connections are allowed.
After sometime (18-20mins) the build just times out with a 'Failed to instantiate class stepDefinitions.LoginSUT'.
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running cucumber.CucumberRunner
Starting ChromeDriver 2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e) on port 8791
Only local connections are allowed.
[1556614819.067][SEVERE]: Timed out receiving message from renderer: 600.000
Starting ChromeDriver 2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e) on port 8470
Only local connections are allowed.
[1556615421.440][SEVERE]: Timed out receiving message from renderer: 600.000
Starting ChromeDriver 2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e) on port 10001
Only local connections are allowed.
[1556616023.903][SEVERE]: Timed out receiving message from renderer: 600.000
7 Scenarios (7 failed)
28 Steps (7 failed, 21 skipped)
30m7.588s
Here is the snapshot from the Jenkins test results. It seems like something is blocking it but I have not been able to figure out. Any suggestions would be greatly appreciated.
My CucumberRunner.java class
//always run this as part of the cucumber class
@RunWith(Cucumber.class)
// additional options for this cucumber class
@CucumberOptions(
features = { // "src/test/resources/features/WebCorporateJourney.feature"//,
"src/test/resources/features/WebRetailJourney.feature" },
glue = { "stepDefinitions" },
plugin = {"com.cucumber.listener.ExtentCucumberFormatter:target/cucumber-reports/report.html" },
monochrome = true)
// bridges between feature file and step definition and help them talk to each
public class CucumberRunner {
@AfterClass
public static void writeExtentReport() {
Reporter.loadXMLConfig(new File("config/report.xml"));
}
}
Edit-1: Adding code as requested
My AbstractDriver.Java class
public class AbstractDriver {
protected static WebDriver driver;
protected WebDriver getDriver() {
// System.setProperty("webdriver.gecko.driver", "C:\\geckodriver.exe");
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
// if driver hasn't instantiated then instantiate it
if (driver == null) {
// instantiates the driver
driver = new ChromeDriver();
// driver = new FirefoxDriver();
}
// returns same instance of the driver
return driver;
}
}
My LoginSUT.java stepDefinition
public class LoginSUT extends AbstractDriver {
WebDriver driver = getDriver();
@Given("^user is on website$")
public void user_is_on_website() throws Throwable {
// passing admin credentials
driver.get("http://admin:[email protected]/");
}
@When("^user enters credentials$")
public void when_user_enters_credentials() throws Throwable {
// Maximising the Browser window
driver.manage().window().maximize();
// Accepting Cookies
driver.findElement(By.xpath("//*[text()='Accept']")).click();
}
@Then("^user is logged on$")
public void user_is_logged_on() throws Throwable {
boolean isDisplayed = driver.findElement(By.xpath("//*[text()='my text to verify']")).isDisplayed();
if (isDisplayed) {
System.out.println("");
System.out.println("USER VERIFICATION: User logged on successfully");
} else {
System.out.println("USER VERIFICATION: User failed to logon");
}
}
}
Edit-2: The tests from Command line were working but through Jenkins were failing
Upvotes: 0
Views: 567
Reputation: 195
After looking around for solution. I found out that Jenkins was installed on my machine as Windows service and the Jenkins Logon properties to allow the interaction was disabled. So I,
open Services -> look for Jenkins -> right-click Properties -> under Log On tab tick the box Allow service to interact with desktop
This change initiated my cucumber tests and I was able to view my tests being run under 'Console Output'
Upvotes: 1