问题
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