MAINTENANCE MODE
Project is no longer being updated but will stay here as portfolio artefact and reference implementation.
Allows automation testers to write feature files for Cucumber and implement step definitions in basic Java classes. ngWebDriver (Protractor) offers extended support for Angular/JS web applications.
Test script logic is implemented directly in step definitions using Dependency Injection (DI) to focus test automation on developing tests instead of keeping up with page objects. An intelligent UI Map serves as the central object repository of web element locators.
project.properties
ap.auth=http://automationpractice.com/index.php?controller=authentication&back=my-account
ui-map.properties
# User Interface (UI) Map
# Patterns
# ui.element.key=locator:selector
# ui.element.key=css_containing_text:selector|text
# ui.element.key=by_all:key1|key2|keyN
# ui.element.key=by_chained:key1|key2|keyN
# Selenium Locators
# id, name, link_text, partial_link_text, tag, class, css, xpath, by_all,
# by_chained, by_id_or_name
# ngWebDriver (Protractor) Locators
# binding, model, button_text, css_containing_text, exact_binding,
# exact_repeater, options, partial_button_text, repeater
#------------------------------------------------------------------------------#
ap.email.create=by_id_or_name:email_create
ap.submit.create=by_id_or_name:SubmitCreate
ap.page.heading=class:page-heading
Feature / Gherkin
Given I Am At Page: 'ap.auth'
When I Enter Email: 'username@xyz.com'
Then I Should See Page Heading: 'CREATE AN ACCOUNT'
Step Definition
private Selenium selenium = null; // Extended Selenium API
// PicoContainer injects shared context
public NetIncomeSteps(ContextSteps contextSteps) {
selenium = contextSteps.getSelenium(); // Instantly begin using API
}
@Given("I Am At Page: {string}")
public void I_Am_At_Page(String key) throws Throwable {
// Use key from project.properties for app settings
selenium.navigate(key); // 1
}
@When("I Enter Email: {string}")
public void I_Enter_Email(String email) throws Throwable {
// Use key from ui-map.properties for web elements
selenium.type(email, "ap.email.create"); // 2
selenium.click("ap.submit.create"); // 3
}
@Then("I Should See Page Heading: {string}")
public void I_Should_See_Page_Heading(String expected) throws Throwable {
// Use fluent assertion
Assertions.assertThat(selenium.refreshAndTextToBePresent(expected, "ap.page.heading")).isTrue(); // 4
}
4 lines of actual test script, 1 class.
[ Back ]
- Selenium WebDriver 3 for browser automation with extended API
- WebDriverManager for automatic management of webdriver binaries (IE11, Edge, Chrome, Firefox)
- ngWebDriver (Protractor) for Angular/JS support
- Cucumber-JVM 4 for behavior-driven testing
- PicoContainer for Dependency Injection module
- AssertJ for fluent assertions
- SLF4J / Log4j2 for logging mechanism
- Masterthought / Extent Reports / Allure for dynamic HTML test reports
- iText for handling PDF files
- POI for handling office documents (Word, PowerPoint, Excel)
- Fillo for SQL-like manipulation of Excel files
[ Back ]
- JDK 1.8 or higher
- Eclipse IDE / VSCode / IntelliJ (install relevant Cucumber plugins)
- Git
- Maven
- Cmder (optional, includes Git for Windows)
[ Back ]
The framework is running tests against 2 applications:
No further configurations needed at this point. The tests will run in headless browser mode using ChromeDriver as defined in framework.properties
.
To run the tests:
Git Bash or Cmder is recommended.
$ cd /path/to/workspace/
$ git clone <repo-url>
$ cd jcucumberng-framework/
$ mvn verify
Maven performs a one-time download of all dependencies. Execute mvn verify
again if needed after the downloads complete to begin running the tests.
Output:
6 Scenarios (6 passed)
22 Steps (22 passed)
1m37.038s
[ Back ]
HTML, JSON, XML test reports and logs are created in the /target/
directory after the build.
Cucumber-JVM ships with its default HTML reporter. Best for debugging scripts.
Generate report into directory: /target/cucumber-html-default/
mvn verify
Output:
Animated visuals with colorful graphs and charts are generated by 3 different reporting plugins. Best for stakeholder demos.
This report is standalone that can be zipped and emailed to clients. HTML files can be viewed locally using any browser.
Generate report into directory: /target/cucumber-html-reports/
mvn verify
Output:
This report is standalone that can be zipped and emailed to clients. HTML files can be viewed locally using any browser.
Generate report into directory: /target/cucumber-extentreports/
mvn verify
The same command generates Masterthought and Extent Reports.
Output:
This report is a single page application (SPA). Dynamic attributes use AJAX and need to be launched from a running web server to view.
Method 1: Generate report into temp folder and start local web server (launches browser)
mvn verify
mvn allure:serve
Method 2: Combine commands (run tests and invoke all reporting plugins)
mvn verify allure:serve
Output:
Logs are written to a daily rolling file. Executions from the previous day are saved with a datestamp. Best for debugging scripts.
Directory:
target/
|__ test-logs/
|__ jcucumberng_2019-06-21.log
|__ jcucumberng_2019-06-22.log
|__ jcucumberng_2019-06-23.log
|__ jcucumberng.log
Output:
[INFO ] 2019-06-28 16:58:28,920 ContextSteps.setUp() - BEGIN TEST -> Verify Page Title
[INFO ] 2019-06-28 16:58:28,921 ContextSteps.setUp() - Browser=CHROME32_NOHEAD
[INFO ] 2019-06-28 16:58:30,618 ContextSteps.setUp() - Screen Resolution (WxH)=1366x768
[DEBUG] 2019-06-28 16:59:49,148 GlobalSteps.I_Am_At_Page() - Page URL=http://simplydo.com/projector/
[DEBUG] 2019-06-28 16:59:49,505 GlobalSteps.I_Should_See_Page_Title() - Page Title=Simply Do - Balance Projector
[INFO ] 2019-06-28 16:59:49,863 ContextSteps.tearDown() - END TEST -> Verify Page Title - PASSED
[ Back ]
Copyright 2018 Katherine Rollo
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.