Cucumber Java latest version - java

From where I can get latest Test Runner class format and cucumber dependencies for Java. I have old dependencies and it was working but now these are too old and does not. I created my new POM file but now my TestRunner file have red error lines and I can not run my tests. I have copied my old and new dependencies below. Please let me know what I am missing here. Do I need more dependencies or these are enough.
Old POM: (with old dependencies I got the following error when I try to run my feature file:
cucumber.runtime.CucumberException: Unknown option: --plugin
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.1.8</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.1.8</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.42.2</version>
</dependency>
</dependencies>
NEW POM: (if I use following new dependencies, my TESTRUNNER has red lines under"#CucumberOptions"
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-picocontainer -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.141.59</version>
</dependency>

No, I manually update my pom.xml file. Got the new dependencies from maven repository.

Related

I'm using eclipse and creating BDD framework . In my runner file, Import cucumber.api is not resolved How to fix this issue?

I'm using eclipse and creating BDD framework . In my runner file, Import cucumber.api is not resolved How to fix this issue?
Attached test runner class
This is my POM file. I think my jar file has some kind of issue which i'm not able to figure out as I'm beginner in automation.
<dependencies>
<!-- To download Selenium-java Jar file-->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.141.59</version>
</dependency>
<!-- To download junit Jar file-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!-- To download cucumber java Jar file-->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
<!-- To download cucumber api Jar file-->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-api</artifactId>
<version>1.2.4</version>
</dependency>
<!-- To download cucumber Jvm deps file-->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.5</version>
</dependency>
<!-- To download cucumber junit file-->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
</dependency>
<!-- To download cucumber extentreport file-->
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.0.2</version>
</dependency>
<!-- To download extent report file-->
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.2</version>
</dependency>
</dependencies>
</project>
I have installed Java 8 version and all got resolved suddenly.

I am trying to launch chrome browser using selenium and maven dependencies getting issue like java.lang.NoSuchFieldError: INSTANCE

I am using below versions of selenium java and server and cucumber dependencies.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.47.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.47.1</version>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>0.1.0</version>
</dependency>
info.cukes cucumber-java 1.1.8
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.1.8</version>
</dependency>
com.theoryinpractise cucumber-testng-factory 1.0.1
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-html</artifactId>
<version>0.2.6</version>
</dependency>
But, If i am using same versions of jar files in ant and trying to launch chrome browser it is working. If i am using same version of dependencies in maven getting issue for launching chrome browser.
Getting below error for maven:
/* java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.(DefaultHttpRequestWriterFactory.java:52)
at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.(DefaultHttpRequestWriterFactory.java:56)
at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.(DefaultHttpRequestWriterFactory.java:46)
at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.(ManagedHttpClientConnectionFactory.java:72)
at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.(ManagedHttpClientConnectionFactory.java:84)
at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.(ManagedHttpClientConnectionFactory.java:59)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager$InternalConnectionFactory.(PoolingHttpClientConnectionManager.java:487)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:147)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:136)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:112)
at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:74)
at org.openqa.selenium.remote.internal.HttpClientFactory.(HttpClientFactory.java:57)
at org.openqa.selenium.remote.internal.HttpClientFactory.(HttpClientFactory.java:60)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.getDefaultHttpClientFactory(ApacheHttpClient.java:252)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.(ApacheHttpClient.java:229)
at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:96)
at org.openqa.selenium.remote.HttpCommandExecutor.(HttpCommandExecutor.java:70)
at org.openqa.selenium.remote.HttpCommandExecutor.(HttpCommandExecutor.java:58)
at org.openqa.selenium.remote.service.DriverCommandExecutor.(DriverCommandExecutor.java:49)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:138))*/
You could try following set of selenium dependencies:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.14.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.14.0</version>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>0.1.0</version>
</dependency>
...
I have used below dependencies
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.141.59</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>25.0-jre</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-exec -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-exec</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.28.0</version>
</dependency>

Which Java library ExtentReportManager is

I've run accross this piece of code somewhere in the internet:
ExtentReportManager reportManager = ExtentReportManager.createInstance();
I was googling half a day to find out which library (maven) this ExtentReportManager is from.
I'm using Maven + Java + Selenium + extentreports
My pom file dependencies:
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>4.0.9</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-html</artifactId>
<version>0.2.6</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-testng -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-testng</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>compile</scope>
</dependency>
No code yet
Looks to me you have to create that class on your own. As an example: https://github.com/sopan-test/SampleSelenium/blob/79b5a5a7129bc99a947ce791ab32f37bade5860d/src/main/java/utils/reporter/ExtentReportManager.java
Actually I think there no method named createInstance by default. you have to define it yourself like in this code.
https://github.com/anshooarora/extentreports-java/issues/1104
I hope it will help you :)

Arquillian and Wildfly: Unable to collect/resolve dependency

I'm trying to write a simple Widlfly container test using Arquillian framework. I have followed the guide from Wildfly container testing guide.
The resulting pom.xml looks like follows.
pom.xml
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>bom-all</artifactId>
<version>${version.wildfly-swarm}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.hibernate.javax.persistence/hibernate-jpa-2.1-api -->
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.2.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mycompany.libs</groupId>
<artifactId>3ds-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.mysema.querydsl/querydsl-apt -->
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>3.7.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.mysema.querydsl/querydsl-jpa -->
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version>3.7.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>jaxrs</artifactId>
<version>${version.wildfly-swarm}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>datasources</artifactId>
<version>${version.wildfly-swarm}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>arquillian-adapter</artifactId>
<version>${version.wildfly-swarm}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>1.4.0.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>arquillian</artifactId>
<version>${version.wildfly-swarm}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.core</groupId>
<artifactId>arquillian-core-api</artifactId>
<version>1.4.0.Final</version>
<scope>test</scope>
</dependency>
</dependencies>
I was following the guide and wrote the JUnit test as follows.
InContainerTest.java
#RunWith(Arquillian.class)
#DefaultDeployment(type = DefaultDeployment.Type.JAR)
public class InContainerTest {
#ArquillianResource
InitialContext context;
#Test
public void testDataSourceIsBound() throws Exception {
DataSource ds = (DataSource) context.lookup("java:jboss/datasources/MyDS");
assertNotNull(ds);
}
}
Whenever I try to run mvn clean install on this code, I'm getting the following error:
org.jboss.arquillian.container.spi.client.container.DeploymentException: Unable to collect/resolve dependency tree for a resolution due to: Failed to collect dependencies at my.company.libs:my-commons:jar:0.0.1-SNAPSHOT, caused by: Server returned HTTP response code: 409 for URL: http://repo.gradle.org/gradle/libs-releases-local/com/mycompany/libs/my-commons/0.0.1-SNAPSHOT/my-commons-0.0.1-SNAPSHOT.pom
Package my-commons comes from the internal repository of my company, but we have Maven's settings.xml configured for it, and it normally works in all other cases.
Any help on this would be highly appreciated.
Please check if the "my-commons" actually contains snapshots or only release artifacts. check if there is some other repo for snapshots and adapt you maven configuration accordingly. See here for reference how to do that: https://maven.apache.org/settings.html#Repositories

#RunWith(Cucumber.class) error. The import cucumber.api.junit.Cucumber; cannot be resolved

I am having this issue on all the cucumber runner files. Using the following dependencies in pom.xml. Any help will be appreciated.
I tried a clean and force update the project and restarted the IDE,
deleted repository folder in .M2 and then clean and force update the projects but it is still not working.
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-core -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-html -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-html</artifactId>
<version>0.2.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-jvm-deps -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/gherkin -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-all -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-picocontainer -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-testng -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-testng</artifactId>
<version>1.2.5</version>
</dependency>
<!-- Extent Reports -->
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.freemarker/freemarker -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.26-incubating</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.masterthought/cucumber-reporting -->
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>2.0.4</version>
</dependency>
1. You have added dependency of Cucumber-TestNG So you have to call Runner class with TestNG Runner syntax.
Syntax for Cucumber with TestNG:
#CucumberOptions(features = "./src/main/java/cfeature", glue = {"stepd"}, monochrome = true, plugin = { "pretty", "html:Reports/cucumber-pretty" })
public class runnerDemo extends AbstractTestNGCucumberTests {
}
Its removing Junit annotation #RunWith and extends AbstractTestNGCucumberTests class.
2. If you want to Run cucumber test with Junit, You need to replace Cucumber-testng depency with Cucumber-Junit. And your syntax will work fine.
cucumber-core
cucumber-java
cucumber-jUnit
use 1.2.6 version for all in pom.xml
all these dependencies must be in same version in order to solve this issue

Categories