1.0.0 • Published 4 years ago

msg-wdio-cucumber-framework v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

MSG WDIO Automated Tests

Install

run npm i in root directory after git clone git@github.com:MSGTech/msg-wdio-automated-tests.git to install all product dependencies from package.json

Webdriver IO

This project is a NodeJS project built with WebdriverIO v5

Cucumber

This project leverages Cucumber JS as a testing framework

Architecture

Component Object Model

Similar to Page Object Model paradigm, this project uses what we call Component Object Model where each Component Object contains selectors and functions of a specific React Component on msg.com. Files can be seen in /src/component-objects directory

Suites

In both /wdio.LOCAL.conf.js and /wdio.SAUCE.conf.js, there is a suites object that contains suites or groupings of tests. We can add any number of any type of suite depending on our test needs. Currently are Suites are groupings of tests by pages but we plan on extending this to include groupings of tests by components as well

Interact

We leverage the Webdriver IO API in our /src/support/interact.js file. In this file contains all methods we need to create WDIO Elements and call actions on them. This file supports both static and dynamic element interactions.

Feed Selectors

Found in /src/support/feed-selectors, these files contain all the methods we use to destructure our fetched JSON files. We then dynamically pass this data to our XPath selectors during test execution.

Required Environment Variables

  • ENV = Environent to run tests against e.g. prod, staging, dev, test, uat
  • AUTH_TOKEN = The Event Engine API token required to interact with our backend
  • SEND_TO_SLACK = If true, will send test information to the Slack channel msg-web-msgcom-update upon start and finish of test run
  • UPLOAD_REPORT_TO_S3 = If true, will upload the Cucumber HTML Report to AWS S3
  • RUN_VISUAL_TESTS = If true, will run our Applitools Visual Tests

Add the following to your ~/.bash_profile

export ENV="prod" 
export AUTH_TOKEN="Bearer ${TOKEN}" (ask someone on team to provide token)
export SEND_TO_SLACK="false"
export UPLOAD_REPORT_TO_S3="false"
export RUN_VISUAL_TESTS="false"

The only variable you should be changing when running from your local machine is ENV

Test Execution

There is currently three different ways you can execute tests in this framework depending on your needs.

Running tests locally

We run tests locally when building or debugging single tests. You can run a single test by passing the path to that test in the debug array inside of wdio.LOCAL.conf suites object. An example of this looks like debug: ["./src/features/lost*/msgcom-1051*.feature"] where a single test is passed to our debug suite. We can then run this suite with the following command from the root of our project directory - ./node_modules/.bin/wdio wdio.LOCAL.conf.js --suite debug.

I recommend you create an alias to this command in your ~/.bash_profile so you don't need to type this everytime you debug a test. You can do so as such alias localDebug="./node_modules/.bin/wdio wdio.LOCAL.conf.js --suite debug". By doing so, you can simply type localDebug in your terminal.

Running test in Sauce

We can run tests in sauce by running wdio.SAUCE.conf config in our root directory with ./node_modules/.bin/wdio wdio.LOCAL.conf.js. This will run all of our tests from your local machine in Sauce using all of the browsers specified in the capabilities array of objects in that config. capabilities: [{ }] We currently test Chrome (latest), FireFox (latest), IE 11, Edge 17 and Safari 12. You can also specific a group to run against as mentioned above and can also create an alias as well if you want to debug tests on certain browsers - alias sauceDebug="./node_modules/.bin/wdio wdio.SAUCE.conf.js --suite debug"

Running tests in Jenkins

We can also run tests on Jenkins so we don't consume resources on our local environment. The job is located here. Once there:

  • Click Build with Parameters
  • Select the Environment you want to run against
  • Select the Suite you want to run against
  • Select the Location you want to run against
  • Select if you want to run Visual Tests with Applitools
  • Select if you want to send slack notifications with test run information
  • Select if you want upload the report to S3
  • Specifiy the branch you want to run against