Automation is a project that solves time problems when it comes to performing quality tests on a functionality of a juggler project, which involves constantly performing the same procedure to verify that the specific application continues to function during code maintenance.
To initialize a project, the following packages must be installed so that the different automated tests and their report can be created:
npm i chai
npm i mocha
npm i mocha-tags
npm i juglar.automation.framework
npm i mochawesome-report-generator
To create a test scenario, the scenario to be tested must be determined. For practical cases, the search test on YouTube for a song is carried out. To start you have to create the test file in this case ./test/youtube.test.js which will determine the actions to be performed in the scenario to be tested.
Example - navigating to https://www.youtube.com and search baby shark
Save file as youtube.test.js
var youtubeAction = require('../Actions/youtubeAction');
var automation = require('juglar.automation.framework');
const { expect } = require('chai');
var tags = require('mocha-tags');
var contexto;
var inicio = async () => { contexto = await automation.run(); };
var cierre = async () => { await automation.closeBrowser(contexto); };
tags('smoke_test').
describe("ingreso a youtube", async () => {
describe("Se realiza la busqueda de la cancion Baby Shark", async () => {
before(async () => { await inicio(); });
after(async () => { await cierre(); });
step("Se ingresa a youtube", async () => {
await youtubeAction.ingresar(contexto, url);
});
step("Se realiza la busqueda de la cancion Baby Shark", async () => {
let cancion = "baby shark";
await youtubeAction.iniciarBusqueda(contexto, cancion);
});
});
});
Save file as actions/youtubeAction.js
var youtubePage = require("../Page/youtubePage");
module.exports = {
ingresar: async (context, url) => {
/*
* @desc navega a la pagina
* @param {string} title
*/
await youtubePage.cambiarUrl(context, url);
},
iniciarBusqueda: async (context, package) => {
/*
* @desc navega a la pagina
* @param {string} package
*/
await youtubePage.fillSearch(context, package);
await youtubePage.pressSearch(context);
},
};
Save file as actions/youtubeAction.js
var youtubePage = require("../Page/youtubePage");
module.exports = {
ingresar: async (context, url) => {
/*
* @desc navega a la pagina
* @param {string} title
*/
await youtubePage.cambiarUrl(context, url);
},
iniciarBusqueda: async (context, package) => {
/*
* @desc navega a la pagina
* @param {string} package
*/
await youtubePage.fillSearch(context, package);
await youtubePage.pressSearch(context);
},
};
Save file as actions/youtubeAction.js
var youtubeLocator = require("../Locators/youtubeLocator")
var automation = require('juglar.automation.framework');
module.exports = {
cambiarUrl : async (context, url) => {
/*
* @desc Ingresa a la página inicial del sitio
* @param {string} url: url a la que se va a dirigir
*/
await automation.setUrl(context, url, 120)
},
fillSearch: async (context, title) => {
/*
* @desc rellena campo titulo
* @param {string} title: titulo del video
*/
await automation.input.fill(context, youtubeLocator.campoSearch, title)
},
pressSearch: async (context) => {
/*
* @desc inicia la accion de buscar presionando el boton de busqueda
*/
await automation.click(context, youtubeLocator.botonSearch)
},
}