Not able to fetch correct data while executing 2 queries in BeforeAll function in protractor

筅森魡賤 提交于 2019-12-11 17:53:16

问题


I am using protractor 5.2.2. and cucumber 3.2.0.I am executing 2 queries in Before All function for fetching the data from the DB.But i need to execute in a way that after executing first query completely, then only i need to start executing the second query(because i am using the 1st query result in 2nd query and i need to catch the 2nd query result before starting all scenarios.).The code i have given in the BeforeAll function is given below

var Connection = require('tedious').Connection;
var Request = require('tedious').Request;

var config = 
{
 userName: 'xxx', 
 password: 'xxxx', 
 server: 'xxxx', 
 options: 
    {
       database: 'xx' ,
       encrypt: true,
       rowCollectionOnRequestCompletion: true
    }
}
var connection = new Connection(config);

connection.on('connect', function (err) {
    if (err) {
        console.log(err);
    }
    else {
        request1 = new Request("EXEC [dbo].[usp_GetPost]", function (err, rowCount, rows) {
            if (err) {
                console.log("Error");
            }
        });

        connection.execSql(request1);


        request2 = new Request("select * from [dbo].[Post_Automation] ", function (err, rowCount, rows) {

        });
        request2.on('row', function (columns) {
            var row = {};
            columns.forEach(function (column) {
                row[column.metadata.colName] = column.value;
            });
            post_details.push(row);
        });
        connection.execSql(request2);
    }
});

How can i do this.Thanks in advance.

来源:https://stackoverflow.com/questions/52754976/not-able-to-fetch-correct-data-while-executing-2-queries-in-beforeall-function-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!