Coming from a Java+WebDriver background, I am new to Protractor, WebdriverJS, and Jasmine. In the image displayed, my goal is to hover over all bubbles and retrieve the tool tip values (city, sold, connected), assign them as objects to an array, and return it to the calling function. Could someone guide me on how to achieve this - creating an array of objects in this particular scenario? I am looking to assert it from my spec file.
Upon calling this function, return arr; executes before the remaining code, likely due to its asynchronous nature.
this.getSalesVolumeDistribution = function() {
var arr = [];
var icons = element.all(by.css('#map-container svg>circle'));
icons.map(function(elm) {
browser.actions().mouseMove(elm).perform();
var toolTipCity = element(by
.css('#map-container g.highcharts-tooltip tspan:nth-of-type(2)'));
var toolTipUnitsSold = element(by
.css('#map-container g.highcharts-tooltip tspan:nth-of-type(3)'));
var toolTipUnitsConnceted = element(by
.css('#map-container g.highcharts-tooltip tspan:nth-of-type(4)'));
toolTipCity.getText().then(function(text) {
var cityVal = text.replace('City: ', '').replace(',', '');
console.log(text.replace('City: ', '').replace(',', ''));
var soldVal = toolTipUnitsSold.getText().then(function(text) {
return text.replace('Units Sold: ', '').replace(',', '');
});
var connVal = toolTipUnitsConnceted.getText().then(function(text) {
return text.replace('Units Connected: ', '');
});
arr.push({
city: cityVal,
sold: soldVal,
conn: connVal
});
});
});
return arr;
};