https://youtu.be/vHzMJuc9Zuk?list=PLFGoYjJG_fqoBFPevCDZDCufDX5h-o3yO
Git Repo: https://github.com/naveenanimation20/CucumberSeleniumFramework.git
General Map of a CucumberJVM Project
- Framework
- Cucumber - JVM/Ruby
- JBehave
- BDD Language - Gherkin <-- annotation conventions, not really a language
- Feature File - login.feature - Gherkin
- Feature Name
- Description
- Scenario
- Scenario Ouline
- Keywords
- Given
- When
- Then
- As
- But
- *
- Feature Name
- Step Definition
- Selenium
- Annotations
- Java
- Test Runner
- JUnit
- Code to run feature
- Generate the output/report
- Feature File - login.feature - Gherkin
- Selenium Steps
- open browser
- login
Eclipse 'Natural' Plugin
- Install Eclipse Natural cucumber/Gherkin plugin
- Might need to locate online, THEN drag component over to EclipseIDE as searching Marketplace renders many results
Create Maven Project
Create Project > Mave Project
Select simple template ( no automatic POM adds )
Cucumber POM Considerations
- Cucumber is VERY finicky with versions of the various dependencies & plugins
- Visit mvcnrepository to hash things out
info.cukes » cucumber-java : 1.2.5
https://mvnrepository.com/artifact/info.cukes/cucumber-java/1.2.5
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
nfo.cukes » cucumber-core : 1.2.5
https://mvnrepository.com/artifact/info.cukes/cucumber-core/1.2.5
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-core -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.5</version>
</dependency>
info.cukes » cucumber-jvm-deps :1.0.5
https://mvnrepository.com/artifact/info.cukes/cucumber-jvm-deps/1.0.5
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-jvm-deps -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.5</version>
<scope>provided</scope>
</dependency>
info.cukes » gherkin : 2.12.2
https://mvnrepository.com/artifact/info.cukes/gherkin/2.12.2
<!-- https://mvnrepository.com/artifact/info.cukes/gherkin -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
<scope>provided</scope>
</dependency>
info.cukes » cucumber-junit : 1.2.5
https://mvnrepository.com/artifact/info.cukes/cucumber-junit/1.2.5
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
https://mvnrepository.com/artifact/junit/junit/4.12
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
net.sourceforge.cobertura » cobertura : 1.9.4.1
https://mvnrepository.com/artifact/net.sourceforge.cobertura/cobertura/1.9.4.1
<!-- https://mvnrepository.com/artifact/net.sourceforge.cobertura/cobertura -->
<dependency>
<groupId>net.sourceforge.cobertura</groupId>
<artifactId>cobertura</artifactId>
<version>1.9.4.1</version>
<scope>test</scope>
</dependency>
org.mockito » mockito-all : 1.10.19
https://mvnrepository.com/artifact/org.mockito/mockito-all/1.10.19
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
Configure Maven POM
<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>
<groupId>FreeCrmBddFramework</groupId>
<artifactId>FreeCrmBddFramework</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>FreeCrmBddFramework</name>
<url>https://maven.apache.org</url>
<properties>
</properties>
<dependencies>
<!-- Cucumber java -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-core -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.5</version>
</dependency>
<!-- cucumber JVM -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>1.2.5</version>
<type>pom</type>
</dependency>
<!-- Cucumber jvm dependencies -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.5</version>
</dependency>
<!-- Cucumber Reporting -->
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>3.10.0</version> <!-- 1.0.0 -->
</dependency>
<!-- Cucumber Gherkin -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
</dependency>
<!-- cucumber junit -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<!-- JUnit 3.8.1 -->
<!-- <dependency> -->
<!-- <groupId>junit</groupId> -->
<!-- <artifactId>junit</artifactId> -->
<!-- <version>3.8.1</version> -->
<!-- <scope>test</scope> -->
<!-- </dependency> -->
<!-- https://mvnrepository.com/artifact/junit/junit -->
<!-- JUnit 4.4 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- Selenium -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.5.3</version>
</dependency>
<!-- Guava 25.1 - 20.0 missing com.google.common.util.concurrent.SimpleTimeLimiter.create -->
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>25.1-jre</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-picocontainer -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/net.sourceforge.cobertura/cobertura -->
<!-- <dependency> -->
<!-- <groupId>net.sourceforge.cobertura</groupId> -->
<!-- <artifactId>cobertura</artifactId> -->
<!-- <version>2.1.1</version> -->
<!-- <scope>test</scope> -->
<!-- </dependency> -->
<!-- 1.9.4.1 -->
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
<!-- <dependency> -->
<!-- <groupId>org.mockito</groupId> -->
<!-- <artifactId>mockito-all</artifactId> -->
<!-- <version>2.0.2-beta</version> -->
<!-- <scope>test</scope> -->
<!-- </dependency> -->
<!-- 1.10.19 -->
</dependencies>
</project>
Create Package
/src/main/java/Features
Create File
login.feature
Download Eclipse 'Natural' plugin
https://marketplace.eclipse.org/content/natural
-
This will parse Gherkin language
Ran into issue with Maven pulling bad gherkin.jar
java.lang.NoClassDefFoundError: gherkin/formatter/Formatter
- deleted gherkin.jar from the .m2 repo & ran Maven>Update Project.... to resolve
Chrome version, chromedriver version, selenium AND guava versions MUST MATCH
org.openqa.selenium.WebDriverException: unknown error: call function result missing 'value'
(Session info: chrome=67.0.3396.79)
(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:42:44.417Z'
System info: host: 'M6500A', ip: '192.168.0.203', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_161'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{mobileEmulationEnabled=false, hasTouchScreen=false, platform=XP, acceptSslCerts=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, platformName=XP, setWindowRect=true, unexpectedAlertBehaviour=, applicationCacheEnabled=false, rotatable=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f), userDataDir=C:\Users\SiloSix\AppData\Local\Temp\CubicExplorerPortableTemp\scoped_dir15852_26983}, takesHeapSnapshot=true, pageLoadStrategy=normal, unhandledPromptBehavior=, databaseEnabled=false, handlesAlerts=true, version=67.0.3396.79, browserConnectionEnabled=false, nativeEvents=true, locationContextEnabled=true, cssSelectorsEnabled=true}]
Session ID: 490467abb43daa1d68d440f9b5171ac4
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:82)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:45)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:646)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:275)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:99)
at stepDefinitions.LoginStepDefinition.user_enters_username_and_password(LoginStepDefinition.java:43)
at ?.Then user enters username and password(W:/w/svn/Java/FreeCrmBddFramework/src/main/java/Features/login.feature:7)
Chrome Browser 67
Help > About
Google Chrome is up to date
Version 67.0.3396.79 (Official Build) (64-bit)
chromedriver
Check version compatibility to determine which chromedriver is required for current installed browser AND selenium
https://sites.google.com/a/chromium.org/chromedriver/downloads
https://chromedriver.storage.googleapis.com/index.html
https://chromedriver.storage.googleapis.com/index.html?path=2.39/
Selenium 3.5.3
<!-- Selenium -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.5.3</version>
</dependency>
Guava
https://mvnrepository.com/artifact/com.google.guava/guava
Error
- Guava 20.0 was throwing error with Selenium 3.5.3
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.util.concurrent.SimpleTimeLimiter.create
Solution
- Added dependency to POM for "25.1-jre" to resolve
- https://mvnrepository.com/artifact/com.google.guava/guava/25.1-jre
<!-- Guava 25.1 - 20.0 missing com.google.common.util.concurrent.SimpleTimeLimiter.create -->
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>25.1-jre</version>
</dependency>
- Log in to post comments
