1.2.1 • Published 6 years ago

dibellag-automation-framework v1.2.1

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

dibellag-automation-framework

A protractor cucumber automation framework built using the latest versions of each. The goal is to display an automation framework with working examples of how to use these latest packages.

Awesome Commitizen friendly semantic-release Build Status

Dependencies

NOTE: This framework maybe usable on lower versions of node and npm. However, these are the versions this project was built and test with.

npm  ->  5.3.0
node ->  v8.4.0
java -> 8

Supported Browsers

BrowserDescriptionDirect Connect
ChromeWorks with most latest versionsYes
Chrome HeadlessLatest couple versionsYes
Firefox56+Yes
SafariNeeds latest version. Setup required: It can be turned on by opening Safari preferences (Safari > Preferences in the menu bar), going to the Advanced tab, and ensuring that the Show Develop menu in menu bar checkbox is checked. Enable Remote Automation in the Develop menu. This is toggled via Develop > Allow Remote Automation in the menu bar.No

Try it now

NOTES: This will run a set of example scenarios that are setup to outline the latest features of cucumber and how to work it.

npm install
npm test

Available npm scripts

npm scriptdescriptiondefaults
npm testruns report cleanup as pretest, and runs protractor config
npm run test:ciruns tests on grid--seleniumAddress=http://127.0.0.1:4444/wd/hub
npm run test:elementExploreropens protractors elementExplorer, needs to be run after webdriver-manager has been started in a different tab
npm run test:dry-runruns cucumber dry run--browserName chrome
npm run test:unitrun framework unit tests
npm run test:scripts:parallelbash example of parallel
npm run test:scripts:synchronousbash example of synchronous
npm run test:scripts:ignore-failurebash example that ignore the firs task failure and runs second task
npm run report:cleanupdeletes and recreates test/output directory
npm run report:generateruns and opens local html report
npm run webdriver-manager:updateupdates browser drivers
npm run webdriver-manager:startstarts local webdriver server, to be run in a separate tab before running elementExplorer command
npm run webdriver-manager:setupwill update and start webdriver server
npm run lintruns gherkin and eslint rules(including protractor)
npm run lint:fixfixes the lint rules that are able to be fixed automatically
npm run lint:gherkinruns just gherkin lint rules
npm run lint:esruns just eslint rules
npm run commitruns git cz to help format commits to follow semantic release

Available cli flags

cli flagdescriptiondefaults
--parallel-featuresruns each feature with a new browser
--parallel-scenariosruns each scenarios with a new browser
--maxSessionscontrols how many browsers run at the same time. To be used with -p flag.1
--browserNamewhich browser to run the tests in, currently supports (chrome, chrome-headless, firefox, safari)
--cucumberOpts.tagssupports a string tag expression
--featuressupports passing in a glob of features to run

Linters

Resources

JSDOC ESLint Google

Lint rules have been setup based on eslint and google recommendations, along with gherkin and protractor lint rules.

The following lint tasks are available:

"lint": "(npm run lint:gherkin; npm run lint:es)",
"lint:fix": "eslint test/** --fix",
"lint:gherkin": "gherkin-lint",
"lint:es": "eslint test/**"

These are the protractor lint rules that will be turned on. Investigating why it throws error when there isnt a case for it.

TODO: Try adding back: "plugin:protractor/recommended" in the extends, and find out why each rule needs protractor/ in front of it to work.

Settings for protractor rules:

2 - error
1 - warning
0 - off

How to use protractor's elementExplorer

  1. Run the below command in one terminal tab
npm run webdriver-manager:setup

This will update webdriver-manager and start it

  1. Run the below command in a second terminal tab
npm run test:elementExplorer
  1. Testing selectors
You can now navigate to any url and run protractor 
commands to test your selectors and functions.

Bash cli differences

  1. How to run a task one after the other regardless if the first one passes
npm run test:scripts:ignore-failure
  1. How to run tasks synchronously
npm run test:scripts:synchronous
  1. How to run tasks in parallel
npm run test:scripts:parallel

See example of parallel execution in ./test/scripts/parallel.sh

Add a script to the scripts directory

After adding a script to the scripts directory you needs to run the following command to make it executable:

chmod +x fileName

Running tests in parallel

In order to run each feature file with a new browser

npm test -- --parallel-features --browserName chrome

In order to run multiple features in parallel

npm test -- --parallel-features --browserName chrome --maxSessions 2

In order to run each scenario in a new brower

npm test -- --parallel-scenarios --browserName chrome

In order to run each scenario in parallel

npm test -- --parallel-scenarios --browserName chome --maxSessions 2

Pass the maxSessions flag with the number of features/scenarios you want to run in parallel.

Contributing

This project uses Commitizen to enforce Semantic Releases

TODOs

  1. Mock setup
  2. Fuctions for executing requests
  3. Custom reporter
  4. Cross browser support
  5. How to best handle non-angular websites
  6. Create test app to provide examples for the following test cases: 6.1. Angular app 6.2. Non Angular page 6.3. Modals 6.4. Iframes 6.5. New tabs

FAQ

The world instance isn't available in my hooks or step definitions.

This has frequently been caused by the use of ES6 arrow functions. You cannot use ES6 arrow functions for step definitions or hooks because they bind this to the current context which prevents the world instance from being injected.

Why do my definition patterns need to be globally unique instead of unique only within Given, When, Then?

To encourage a ubiquitous, non-ambiguous domain language. Using the same language to mean different things is basically the definition of ambiguous. If you have similar Given and Then patterns, try adding the work "should" to your Then pattern