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
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Jenkins in the Age of Kubernetes: Strengths, Weaknesses, and Its Future in CI/CD
  • Java CI/CD: From Local Build to Jenkins Continuous Integration
  • Travis CI vs Jenkins: Which CI/CD Tool Is Right For You?
  • Recipe To Implement the Jenkins Pipeline For MuleSoft Application [Videos]

Trending

  • How the Go Runtime Preempts Goroutines for Efficient Concurrency
  • Why High-Performance AI/ML Is Essential in Modern Cybersecurity
  • Docker Model Runner: Streamlining AI Deployment for Developers
  • A Modern Stack for Building Scalable Systems
  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.1K 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("vishnu@vmail.com");
}

@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
  • Java CI/CD: From Local Build to Jenkins Continuous Integration
  • Travis CI vs Jenkins: Which CI/CD Tool Is Right For You?
  • Recipe To Implement the Jenkins Pipeline For MuleSoft Application [Videos]

Partner Resources

×

Comments
Oops! Something Went Wrong

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

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!