mercredi 11 avril 2018

Protractor - javascript enums in tests with suggestion

I want to create simple enums for my tests in Protracot- javascript but I'm not sure how to implement it. So, I would like to create simple emum class with different enums - for example enum with color and css selector.

example enum:

var Enums = function () {

this.Colors = function(){
    return defCol = {
        'WHITE': 'cssSelector1',
        'BLACK':"cssSelector2,
        'RED': 'cssSelector3',
        }
    }();

}

module.exports = new Enums;

Later I want to import this class to eg. SearchPage.js and use it in function that I will use in test. When I will use this function in test I would like that those enums are suggested in function parameters. Im our app we have a lot od filters (drop downs), so this solutions with enums will help us a lot.

This is how we have it implement in other project (java): Enum in Page class:

    public enum RestrictionType {
    WHITE("cssSelector1"),
    BLACK("cssSelector2"),
    RED("cssSelector3");

    private String restriction;

    RestrictionType(String restriction) {
        this.restriction = restriction;
    }

    public String restrictionName() {
        return restriction;
    }
}

and in test scenario we use it like that

public CreateBundleScenario restriction(RestrictionType restrictionType) {
        this.restrictionType = restrictionType;
        return this;
    }


.selectRestriction(restrictionType.restrictionName())

in .selectRestriction() in bracket are suggestet values from ENUM

Aucun commentaire:

Enregistrer un commentaire