Reputation: 41
i am looking to extract the value from the following recordset object to compare it with a value of a web element using protractor. Please help
recordset: [ { '': 178 } ],
I converted it to a json string using stringify, unable to proceed after that
var a = JSON.stringify(count);
and the value becomes .[ { '': 178 } ]
it('tests db connection', function (done) {
ConnectDB().then(function _onSuccess(_returned){
//console.log(_returned.recordset[0]);
var count =_returned.recordset;
console.log(count)
browser.recordcount = count;
done();
}).catch(function _onFailure(err){
done.fail(err);
I tried to split the string using : but i am getting the value 178}] , can someone suggest a possible solution?
Upvotes: 0
Views: 538
Reputation: 309
Lets say:
var a = JSON.stringify(count);
console.log(a);
[ { '': 178 } ]
Then you can extract 178 using this code:
var cout =x[0][''];
console.log(cout);
178
Upvotes: 0