量角器:如何拉伸和替换元素?

Protractor: How I can stretching and replasing elements?

我有这样的表格:

而且我想模拟列拉伸。我也可以更改列标题的位置。所以我想效仿它。我想我应该使用 webdrivers 方法。但是我看不懂是哪一种。

这听起来像是 dragAndDrop() browser action 的一个很好的用例:

browser.actions().
    dragAndDrop(elm, {x: 400, y: 20}).
    perform();

您还可以从一个元素拖放到另一个元素:

browser.actions().
    dragAndDrop(elm, targetElm).
    perform();

而且,仅供参考,这是规范:

/**
 * Convenience function for performing a "drag and drop" manuever. The target
 * element may be moved to the location of another element, or by an offset (in
 * pixels).
 * @param {!webdriver.WebElement} element The element to drag.
 * @param {(!webdriver.WebElement|{x: number, y: number})} location The
 *     location to drag to, either as another WebElement or an offset in pixels.
 * @return {!webdriver.ActionSequence} A self reference.
 */
webdriver.ActionSequence.prototype.dragAndDrop = function(element, location) {
  return this.mouseDown(element).mouseMove(location).mouseUp();
};

我想做一个有趣的笔记。我的看法:

<div class="n-grid-col-resize ng-scope" ng-if="column.resizable" ng-dblclick="menuOptions.onColumnAutoSize(column)" jQuery111202531640218477999="237"/>

图中是竖线,我要点击移动。很长一段时间我都不明白为什么 dragAndDrop()、doubleClick() 等方法不能使用它。答案很简单。我应该得到一个物体的中心。所以,而不是:

browser.actions().doubleClick(my_elem).perform();

我应该写:

browser.actions().mouseMove({x: x1, y: x2}).doubleClick().perform();

其中

 var x1 = my_elem_x + my_elem_width/2;                
 var x2 = my_elem_y + my_elem_height/2;