There's no specific code that directly integrates Selenium Cucumber with Jira in IntelliJ. What we need to do is set up a Selenium Cucumber project and enable Jira integration in IntelliJ. I've provided a simple example below.
- Create a new Maven project in IntelliJ and add the necessary dependencies in
pom.xml:
<dependencies>
<!-- Cucumber -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>6.10.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>6.10.0</version>
<scope>test</scope>
</dependency>
<!-- Selenium -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<!-- TestNG -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
- Create a package called
src/test/java/features and put a new feature file called Login.feature with the following content:
Feature: Login functionality
Scenario: Successful login
Given I am on the login page
When I enter valid credentials
Then I should see the dashboard page
- Create a
Steps package under src/test/java and create a LoginSteps.java:
import io.cucumber.java.en.*;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
public class LoginSteps {
WebDriver driver;
@Given("I am on the login page")
public void i_am_on_the_login_page() {
System.setProperty("webdriver.chrome.driver", "path/to/chromedriver");
driver = new ChromeDriver();
driver.get("https://your-login-page-url.com");
}
@When("I enter valid credentials")
public void i_enter_valid_credentials() {
WebElement usernameInput = driver.findElement(By.id("username"));
WebElement passwordInput = driver.findElement(By.id("password"));
usernameInput.sendKeys("your_username");
passwordInput.sendKeys("your_password");
passwordInput.submit();
}
@Then("I should see the dashboard page")
public void i_should_see_the_dashboard_page() {
driver.findElement(By.className("dashboard-class-name")).isDisplayed();
driver.quit();
}
}
- Create a test runner class
LoginTest.java in a new package src/test/java/runner:
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(
features = "src/test/java/features/",
glue = "src/test/java/Steps/"
)
public class LoginTest {
}
- Configure Jira integration in IntelliJ as per the previous response's step #4.
Now you have a working Selenium Cucumber framework in IntelliJ. The integration with Jira is achieved through the Jira plugin for IntelliJ. You can create tasks in IntelliJ that link to Jira issues, and use smart commits to interact with Jira when committing and pushing your code.