量角器 ManagedPromise::2516 {[[PromiseStatus]]: "pending"}

Protractor ManagedPromise::2516 {[[PromiseStatus]]: "pending"}

我在 Jasmine 中使用量角器,并且使用页面对象模式。在我的一个页面对象中,我试图将鼠标悬停在饼图上。但是当我使用以下方法时,它无法使用 getDisHoverPoint() 获取 x 坐标的值。当我为 getDisHoverPoint() 放置一个记录器时,它 returns ManagedPromise::2516 {[[PromiseStatus]]: "pending"}。请帮忙。

this.hoverMouse = function() {
    var dis = element(by
            .css('#piecontainer .highcharts-series>path[fill="#434348"]'));

    function getDisHoverPoint() {
        return dis.getSize().then(function(text) {
            return (text['height'] / 2).toFixed(0);
        });
    }

    browser.actions().mouseMove(dis, {
        x : getDisHoverPoint(),
        y : 0
    }).perform();
}

您必须解决 getDisHoverPoint() 以获得 x 的实际值:

this.hoverMouse = function() {
    var dis = element(by
            .css('#piecontainer .highcharts-series>path[fill="#434348"]'));

    function getDisHoverPoint() {
        return dis.getSize().then(function(text) {
            return (text['height'] / 2).toFixed(0);
        });
    }

    getDisHoverPoint().then(function (value) {
        browser.actions().mouseMove(dis, {
            x : value,
            y : 0
        }).perform();
    });
}