If you want to convert String
to a Number
you can either use parseFlaot
for floating point numbers or parseInt
for integers. As long as it will not start with letter characters it will cut off the non number part. Also watch out with parsing the number as it will also cut of leading 0s in front of a number - you might want to improve your regexp to grab only the number from where you expect it to be in the string to make it more bulletproof.
Also you don't need to use element.all(locator).get(0)
, element(locator) for multiple occurrences will always return first element found.
element(by.css(".list-group-item.ng-binding.ngscope")).getText()
.then(function(text){
var listItemText = text.replace(/[\r\n]/g, "");
expect(praseFloat(listItemText)).toBeGreaterThan(0);
});