Framework Setup

Introduction

In this section, we will create a single configuration file to store all our Test Runner settings, which will be used when running any of our tests. This file is pretty large, but thankfully the Test Runner provides a utility which asks a series of questions in order to automatically create an appropriate configuration file for us.

Let’s begin 🙂

WDIO Test Runner utility

  1. Open up Terminal (or Command prompt) and change directory (cd) into the project root again…
    cd webdriverio-framework (or whatever your path is)
  2. Enter in the following to begin the Test Runner utility…
    ./node_modules/.bin/wdio
    It will recognise that we haven’t yet created a configuration file, so will begin asking us questions in order to create an appropriate one for us.

Where do you want to execute your tests?

  1. For the first question, select to execute our tests on our local machine like below, and press Enter…

Which framework do you want to use?

  1. For the second question, select to use the Cucumber framework like below, and press Enter…

    • Select ‘Yes’ when asked to install the framework adapter for Cucumber…

Where are your Feature files located?

  1. For the third question, enter in an appropriate relative path to where our Cucumber Feature files will exist and press Enter (it is common practice to have a ‘/src/resources’ directory and then have a ‘/features’ directory within the ‘/src/resources’ directory to keep our Feature files in)…

Where are your step definitions located?

  1. For the next question, enter in an appropriate relative path to where our Step Definition files will exist and press Enter (it is again common practice to keep our Step Definition files in a ‘/src/test/steps’ directory).  Step Definitions are the glue that connects our Cucumber Feature files (written in Gherkin language) to our Javascript code…

Which reporter do you want to use?

  1. Next, select the reporter you want to use when running your tests and press Enter. In this blog series, I will be using Spec reporter due to the output gives on passing and failing test cases. You could instead use another like TestRail if you wanted to push the test results into TestRail (For more information please see http://webdriver.io/v3.4/guide/testrunner/reporters.html)…

Do you want to add a service to your test setup?

  1. Next, we will select to add the Selenium Standalone service, so that we can automatically start an instance of Selenium Standalone before our tests our run (you could alternatively select a cloud-based testing platform like SauceLabs or BrowserStack if your company uses that).  Select ‘Selenium Standalone’ and press Enter…

Level of logging verbosity

  1. Next, select a suitable level of logging to output and press Enter.  For the purpose of this blog series, I will select ‘silent’ so that less noise is output, but you could select ‘verbose’ to output all logs or choose a specific level of logging like ‘error’ to only output that…

In which directory should screenshots gets saved if a command fails?

  1. For the next question, select a suitable relative path to store an screenshots that are taken when a test fails, and press Enter.  For the purpose of this blog series, I will stick to the default directory path…

What is the base URL?

  1. For the last question, enter the Base URL of the website you will be testing and press Enter.  For the purpose of this blog series, I will be showing an example test of going to DuckDuckGo search engine, searching for Reddit, selecting the first result and then asserting that we are indeed on the Reddit home page. Based on this, my base URL will be https://start.duckduckgo.com/

Now that all questions have been answered, the WDIO packages will install. Once complete, a WDIO configuration file (wdio.conf.js) will be created based on all the questions we just answered…

Our WebDriverIO Test Runner is now setup, with its configuration file (wdio.conf.js) existing in our project root.

In the next section, we will begin to create the folder structure for our test framework and add the necessary files.  We will also tweak our Test Runner configuration file a bit to make things run smoother down the line. 🙂

 

 

Liked it? Take a second to support Thomas on Patreon!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.