2

I am working on "Cucumber-Jvm (Using Maven Project) + Selenium WebDriver + PageObjects + Allure Report", I am able to run my script but enable to run my script and also unable generate "Allure" report.

Below are the codes, feature file, pom.xml, etc..

Pom.xml : Reference POM url - https://github.com/allure-framework/allure-cucumber-jvm-adaptor

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>
<name>Allure Cucumber-JVM Adaptor</name>
<artifactId>allure-cucumber-jvm-adaptor</artifactId>
<groupId>ru.yandex.qatools.allure</groupId>
<version>1.4-SNAPSHOT</version>

<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>https://github.com/allure-framework/allure-cucumber-jvm-adaptor</url>
<connection>scm:git@github.com:allure-framework/allure-cucumber-jvm-adaptor.git</connection>
<developerConnection>scm:git:git@github.com:allure-framework/allure-cucumber-jvm-adaptor.git</developerConnection>
</scm>
<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/allure-framework/allure-cucumber-jvm-adaptor/issues</url>
</issueManagement>
<ciManagement>
<system>TeamCity</system>
<url>http://teamcity.qatools.ru/</url>
</ciManagement>
<developers>
<developer>
<id>clicman</id>
<name>Viktor Sidochenko</name>
<email>viktor.sidochenko@gmail.com</email>
</developer>
</developers>
<mailingLists>
<mailingList>
<name>Allure Mailing List</name>
<post>allure@yandex-team.ru</post>
</mailingList>
</mailingLists>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<compiler.version>1.7</compiler.version>
<allure.version>1.4.5</allure.version>
<aspectj.version>1.8.4</aspectj.version>
</properties>
<dependencies>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-core</artifactId>
<version>${allure.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-java-aspects</artifactId>
<version>${allure.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-commons</artifactId>
<version>${allure.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.0</version>
<type>jar</type>
</dependency>

<!--   <dependency>
    <groupId>org.sonatype.oss</groupId>
    <artifactId>oss-parent</artifactId>
    <version>9</version>
</dependency> -->

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
<type>jar</type>
</dependency>
</dependencies>
<build>
<plugins>

<plugin>
    <groupId>org.sonatype.plugins</groupId>
    <artifactId>nexus-staging-maven-plugin</artifactId>
    <version>1.6.5</version>
    <extensions>true</extensions>
    <configuration>
        <serverId>ossrh</serverId>
        <nexusUrl>https://oss.sonatype.org/</nexusUrl>
        <autoReleaseAfterClose>true</autoReleaseAfterClose>
    </configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<!-- parallel execution configuration -->
<parallel>classes</parallel>
<threadCount>8</threadCount>
<includes>
<include>**/*Test.java</include>
</includes>
<testFailureIgnore>false</testFailureIgnore>
<argLine>
-javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
</argLine>
<properties>
<property>
<name>listener</name>
<value>ru.yandex.qatools.allure.cucumberjvm.AllureRunListener</value>
</property>
</properties>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>

Feature file location: src/test/resources and Name of the feature file: OpenAndclose.feature

Feature: OpenAndClose

    Scenario: OpenAndClose Browser
    Given user opened firefox browser
    Then user-entered URL
    Then user closed firefox browser

And codes at: src/test/java

TestRunner class:

package openANDclose;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(dryRun=false, monochrome = true, features= "src/test/resources/OpenAndclose.feature")

public class OpenAndClose_TestRunner {

}

Step Definitions:

package openANDclose;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;

public class OpenAndClose_StepDefinitions {

    public static WebDriver driver;

    @Given("^user opened firefox browser$")
    public void user_opened_firefox_browser() throws Throwable {
            driver=new FirefoxDriver();

    }

    @Then("^user entered url$")
    public void user_entered_url() throws Throwable {
        OpenAndClose_PageObjects.user_opened_firefox_browser(driver);
    }

    @Then("^user closed firefox browser$")
    public void user_closed_firefox_browser() throws Throwable {
        OpenAndClose_PageObjects.user_closed_firefox_browser(driver);
    }

}

Page Object Class:

package openANDclose;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class OpenAndClose_PageObjects {
    public static WebDriver driver ;

    public static WebElement element=null;

    public static WebElement user_opened_firefox_browser(WebDriver driver) {
        driver.get("http://google.co.in");
        return element;
    }

    public static WebElement user_closed_firefox_browser(WebDriver driver) {
        driver.quit();
        return element;
    }
}

After running "Allure" report from command prompt, getting below error message and error report.

Below from: mvn clean test

mvn clean test

Below report from: mvn site

mvn site

  • 1
    First of all a few things: Please don't use underscore in a class name. Second, don't use capital letters in a package name. Third, you have a compilation issue on selenium in your test class. Try adding in selenium in the pom.xml. Though it should have been taken in by cucumber. – Hannibal May 3 '15 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.