Reputation: 59
I'm from WebDriver+Java background and new to Protractor, WebDriverJS and Jasmine. I have a page object and there I'm trying to define a function that will hover over a pie chart on a given X Y coordinates and get the tool tip value and return it back to the calling function. But so far no luck. Can anyone please help me to find a better solution for this?
this.getDisCount = function() {
var dis = element(by
.css('#piecontainer .highcharts-series>path[fill="#434348"]'));
return dis.getSize().then(function(size) {
return (size['height'] / 2).then(function(value) {
return browser.actions().mouseMove(dis, {
x : value,
y : 0
}).perform().then(function() {
return element(by.css('#piecontainer g.highcharts-tooltip tspan:nth-of-type(6)')).getText().then(function(text) {
return text;
});
});
});
});
}
Getting the following exception with the above code.
Upvotes: 1
Views: 1147
Reputation: 1
There is an issue with protractor instance, so try the selenium instance of web driver that can be obtained using browser.driver
and use the dragAndDrop
method for the element which you want to hover.
await browser.driver.actions()
.dragAndDrop(elementToHover, elementToHover)
.perform();
Upvotes: 0
Reputation: 473893
The main problematic part is on this line:
return (size['height'] / 2).then(function(value) {
The size
is an already resolved size object, it is not a promise, the then()
part is not needed.
Also, let the getDisCount()
function return the getText()
promise:
this.getDisCount = function() {
var dis = element(by.css('#piecontainer .highcharts-series>path[fill="#434348"]'));
dis.getSize().then(function(size) {
return browser.actions().mouseMove(dis, {
x : size['height'] / 2,
y : 0
}).perform();
});
return element(by.css('#piecontainer g.highcharts-tooltip tspan:nth-of-type(6)')).getText();
}
Then, once you need the value, resolve the result of the function:
myPageObject.getDisCount().then(function (discountValue) {
console.log(discountValue);
});
Upvotes: 1