Automated tests using Selenium with JS

Some of the tests that I used to automate some manual tests using Selenium WebDriver
My Linkedin»

(back to top)

Built With

The tests were build with Selenium WebDriver and the code is JavaScript.

Additional libraries that were used.

  • JavaScript
  • Mocha
  • Mochawesome
  • Chai

(back to top)

Getting Started

Follow the step-by-step to set up the working enviorment.

Prerequisites

Install Node.js from the website https://nodejs.org/en/

Open CMD Promt and check the version

  • npm
    node --v

Installation

Create new test project folder Open CMD terminal and navigate to the directory of the folder (cd /path/)

  1. Once navigated type in the following command

  2. Clone the repo

    npm init
  3. Install NPM package Selenium-Webdriver

    npm install selenium-webdriver
  4. Set up PATH Environmentals Method 2: Setting ChromeDriver Path in Windows Environment Variables • Step 1: Go to My Computer and Right click to get the context menu. MyComputer Properties • Step 2: Click on the Change Setting on the opened window. Change Settings • Step 3: Click on Advance tab and click on Environment Variables.

  5. Select Path under System Variables and click on Edit.

  6. Step 5: At the end of the string use semicolon and paste the path of the ChromeDriver. On my machine my ChromeDriver exe resides in D:\Drivers\

  7. Install NPM package Google Chrome Driver

    Npm install chromedriver
  8. Install NPM Firefox driver

    npm install geckodriver

Install Chai /for assertions/

Install Mocha for test reporting

We can run the code with npx mocha --no-timeouts /Tests/*.js (the path of the tests) 11.1 We can modify the package.json to "scripts": { "test": "mocha --no-timeouts *js" } and then proceed to execute the tests using the "npm test" in the terminal

We can add --parallel to the package.json - npx mocha --no-timeouts --parallel *.js to run tests simunteniously.

Generating test visualization reports with mochawesome

  1. Install NPM Mochawesome
    npm install mochawesome
    update the package.json to include the following:

"scripts": { "test": "mocha --no-timeouts --parallel --reporter mochawesome --require mochawesome/register *.js" },

Run using npm test

(back to top)

Usage

Use this space to show useful examples of how a project can be used. Additional screenshots, code examples and demos work well in this space. You may also link to more resources.

If you have any jobs offers you can reach me at LinkedIn

(back to top)

Roadmap

  • Add README
  • Update some tests to run in a cloud.
  • Add the tests to Selenium Grid
  • Add some API testing

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Sava Barbarov - savabarbarov96@gmail.com

Project Link: https://github.com/savabarbarov96/testing-repo

(back to top)