Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a protractor.js test from a inquirer.js menu

I'm stuck in a problem. I have a set of end to end tests written with protractor.js and I made a little menu with inquire.js in which I'll select which tests I would like to run. The problem is, I really can't find any information on how to actually link those two projects together so the menu can call a test once selected. Here is a sample of a test and the menu I made:

This is my protractor test:

var session = require('../login.js');

describe('The customer view', function() {

    var physicalPersonRegistration = {};

    physicalPersonRegistration.loginTest = function() {

        it('should Login', function() {
            browser.ignoreSynchronization = true;

            browser.get('http://localhost:8080/project');

            session.username.sendKeys('admin');
            session.password.sendKeys('admin');
            session.submit.click();

            browser.ignoreSynchronization = false;
        });
    };

    //executing tests
    physicalPersonRegistration.loginTest();
});

And this is my inquire.js menu:

  var inquirer = require("inquirer");

  var questions = [

        {
          type: "list",
          name: "tests",
          message: "Which test do you wish to run?",
          choices: [
            "Login Test",
            "Run all Tests"
          ]
        },

    ];

    inquirer.prompt(questions, function(answers) {
      console.log(answers);
});
like image 892
Jean Avatar asked Nov 09 '22 23:11

Jean


1 Answers

The first thing to do is to determine what DOM elements you want to interact with. You can start by using the protractor element explorer. Use that to determine the kinds of locators to use. And then build your test around interacting with the browser.

like image 177
Andrew Eisenberg Avatar answered Nov 15 '22 06:11

Andrew Eisenberg