Coder Social home page Coder Social logo

startrug / cafetownsend.protractortests Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 288 KB

Simple Protractor e2e tests project for Angular app http://cafetownsend-angular-rails.herokuapp.com/

License: MIT License

JavaScript 100.00%
e2e-tests e2e-testing javascript js protractor protractor-e2e-test protractor-tests jasmine-framework automated-testing allure-report

cafetownsend.protractortests's Introduction

Last commit GitHub top language

Protractor e2e tests training project

This is my first automated testing project using JS and Protractor framework. I prepared some test scenarios for Angular app availaible here: cafetownsend-angular-rails.herokuapp.com. By this project, I wanted to get essential knowledge about Protractor framework and its capabilities.

Project structure

  • configuration - there is only one file in that directory conf.js, but is possible to add another configuration file, eg. for CI integration
  • data - in that directory you can find data sets for tests. I prepared 3 files: employees.json, page_info.json and users.json for suitable data. It's possible to use data stored in JSON file in simple way, for example:
let employees = require('../data/employees.json')

if you want to import all data from file - in this case employees.json, or:

let admin = require('../data/users.json').admin;

if you want to import only selected part of data - in this case admin credentials from users.json Now, you have access to imported data sets, for example:

this.logInAsAdmin = function() {
        this.get();
        this.enterUserName(admin.name);
        this.enterUserPassword(admin.password);
        submitForm();
    }
  };

Notice: the code above is a part of login_form.js. Go to this file for more details.

  • helpers - in this directory I stored reusable parts of code to avoid its duplication. There are some methods using in many places, so I decided to place them in common_methods.js. You can import all common methods or one of them and assign it to variable like in examples: example of import all common methods and using one of them
let commonActions = require('../helpers/common_methods.js');
expect(commonActions.isSubmitButtonDisabled()).toEqual('true');

example of import selected method and using it

let createEmployeeFullName = require('../helpers/common_methods').createEmployeeFullName;
let fullName = createEmployeeFullName(employeeToDelete.firstName, employeeToDelete.lastName);

Project features

  • framework follows page object pattern
  • data-driven tests - test data is loading from json files (see: Project structure)
  • easy to generating and attractive reports in Allure with screenshots and nice charts

Getting started

Basic informations about Protractor setup, configuration and writing first test are availaible here: protractor.org

Running tests

For run all tests just open command line in configuration directory and type command:

protractor conf.js

If you want to run specific suites of tests you can use command:

protractor conf.js --suite login,add

You can also run specific files containing tests by using command:

protractor conf.js --specs ../tests/add_employee_spec.js, ../tests/delete_employee_spec.js

Remember not to use spaces between comma and name of suite or file!

Generating reports

After tests run allure-results directory should be saved in main project catalog. For genereting Allure report just open command line in main project directory and use command:

allure serve

Report will be generated in few seconds and opened in your default browser.

The tests report might look like this: Allure report screenshot

What's next?

This simple, training project is still developing. I want to add more scenarios and test cases and refactor a bit existing code and maybe modify project structure ๐Ÿ˜Š EDIT: After many changes, fixes and code refactoring, I decided to leave this project in current state. Maybe I'll back to that with new ideas when I'll learn more about tests automation using JavaScript.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.