量角器将鼠标悬停在 SVG 饼图和 return 工具提示值上的 X Y 坐标上
Protractor hover mouse over X Y coordinates on SVG pie chart and return tool tip value
我来自 WebDriver+Java 背景并且是 Protractor、WebDriverJS 和 Jasmine 的新手。我有一个页面对象,我正在尝试定义一个函数,该函数将悬停在给定 X Y 坐标上的饼图上并获取工具提示值,然后 return 将其返回给调用函数。但到目前为止还没有运气。谁能帮我找到更好的解决方案?
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;
});
});
});
});
}
使用上述代码得到以下异常。
- 失败:(size.height / 2).then 不是函数
在 D:\workspace\eclipse\IotTester\page\UseCase1\HomePage.js:85:32
在 D:\workspace\eclipse\IotTester\node_modules\protractor\built\element.js
:697:28
主要有问题的部分在这一行:
return (size['height'] / 2).then(function(value) {
size
是一个已经解析的大小对象,它不是一个承诺,不需要 then()
部分。
此外,让 getDisCount()
函数 return getText()
承诺:
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();
}
然后,一旦你需要这个值,解析函数的结果:
myPageObject.getDisCount().then(function (discountValue) {
console.log(discountValue);
});
量角器实例存在问题,因此请尝试使用 browser.driver
获取的 Web 驱动程序的 selenium 实例,并对要悬停的元素使用 dragAndDrop
方法。
await browser.driver.actions()
.dragAndDrop(elementToHover, elementToHover)
.perform();
我来自 WebDriver+Java 背景并且是 Protractor、WebDriverJS 和 Jasmine 的新手。我有一个页面对象,我正在尝试定义一个函数,该函数将悬停在给定 X Y 坐标上的饼图上并获取工具提示值,然后 return 将其返回给调用函数。但到目前为止还没有运气。谁能帮我找到更好的解决方案?
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;
});
});
});
});
}
使用上述代码得到以下异常。
- 失败:(size.height / 2).then 不是函数 在 D:\workspace\eclipse\IotTester\page\UseCase1\HomePage.js:85:32 在 D:\workspace\eclipse\IotTester\node_modules\protractor\built\element.js :697:28
主要有问题的部分在这一行:
return (size['height'] / 2).then(function(value) {
size
是一个已经解析的大小对象,它不是一个承诺,不需要 then()
部分。
此外,让 getDisCount()
函数 return getText()
承诺:
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();
}
然后,一旦你需要这个值,解析函数的结果:
myPageObject.getDisCount().then(function (discountValue) {
console.log(discountValue);
});
量角器实例存在问题,因此请尝试使用 browser.driver
获取的 Web 驱动程序的 selenium 实例,并对要悬停的元素使用 dragAndDrop
方法。
await browser.driver.actions()
.dragAndDrop(elementToHover, elementToHover)
.perform();