DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Jenkins in the Age of Kubernetes: Strengths, Weaknesses, and Its Future in CI/CD
  • Integrating Jenkins With Playwright TypeScript: A Complete Guide
  • DORA Metrics: Tracking and Observability With Jenkins, Prometheus, and Observe
  • An Explanation of Jenkins Architecture

Trending

  • Ingesting Fixed-Width Mainframe Files Into Delta Lake: The Details Nobody Writes Down
  • 5 Layers of Prompt Injection Defense You Can Wire Into Any Node.js App
  • You Secured the Code. Did You Secure the Model?
  • Optimizing Databricks Spark Pipelines Using Declarative Patterns
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Cucumber — Selenium — Jenkins Integration

Cucumber — Selenium — Jenkins Integration

This article explains how to integrate automated testing.

By 
Vishnu V user avatar
Vishnu V
·
Updated Jul. 09, 19 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
9.3K Views

Join the DZone community and get the full member experience.

Join For Free

DevOps is on the most widely accepted concept that integrates automated testing into a continuous integration process. Automated testing runs automatically and creates execution reports once it is integrated.

Step 1: Creating Cucumber Selenium Files

Create a Maven project in Eclipse and add the following dependencies in pom.xml:

  1. Selenium Java

  2. Cucumber-Junit

  3. Cucumber-Java

Image title

Creating a Cucumber Feature FIle: Login.Feature

Image title

Create StepDefinition (Selenium) for Feature

package SeCu;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import cucumber.api.java.Before;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;

public class CucSelenium {
WebDriver driver;
@Before public void setUp(){ 
System.setProperty("webdriver.chrome.driver", "src/main/resources/chromedriver.exe");
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 
} 

@Given("User enters url")
public void user_enters_url() {
driver.get("http://demowebshop.tricentis.com/");
driver.findElement(By.linkText("Log in")).click();

}

@And("He enters userName")
public void he_enters_userName() {
// Write code here that turns the phrase above into concrete actions
driver.findElement(By.id("Email")).sendKeys("[email protected]");
}

@When("He enters password")
public void he_enters_password() {
// Write code here that turns the phrase above into concrete actions
driver.findElement(By.id("Password")).sendKeys("123456");

}

@Then("Home page is displayed")
public void home_page_is_displayed() {
// Write code here that turns the phrase above into concrete actions

System.out.println("home page");

//driver.findElement(By.xpath("//*[@value='Log in'])")).click();
driver.findElement(By.xpath("/html/body/div[4]/div[1]/div[4]/div[2]/div/div[2]/div[1]/div[2]/div[2]/form/div[5]/input")).click();

}


}

Create a RunnerFile to Execute- Runner>java

Image title

Note: JSON report is used to create Cucumber reports.

Step 2: Adding the Source Code on GitHub

Create a new repository on GitHub.

Image title

In the Eclipse root folder, right-click and select "Team" and click on share project and click create.

Image title

Provide the URL and credentials of the newly created git repository.

Image title

Select all the unstaged changes and add to staged changes and click on commit and push after providing a commit message.

Image title

Provide the credentials when asked for. Your source code is updated in the GitHub repository.

Image title

Step 3: Configuring Jenkins and Building a Job

In Jenkins, create a new Maven project:

Image title

In the Source code management configuration, select GIT and provide the URL and credentials:

Image title

In the Build Step

Provide the POM.xml path and provide the goal as a clean install:

Image title

Click on Save and Build. You can see a build is created, and if you want to see Cucumber reports post-build, add the Cucumber reports plugin and verify the reports.

Cucumber (software) Integration Jenkins (software) Continuous Integration/Deployment

Opinions expressed by DZone contributors are their own.

Related

  • Jenkins in the Age of Kubernetes: Strengths, Weaknesses, and Its Future in CI/CD
  • Integrating Jenkins With Playwright TypeScript: A Complete Guide
  • DORA Metrics: Tracking and Observability With Jenkins, Prometheus, and Observe
  • An Explanation of Jenkins Architecture

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook