* Configures a drag-and-drop action consisting of the following steps: * * 1. Move to the center of the `from` element (element to be dragged). * 2. Press the left mouse button. * 3. If the `to` target is a plain ./webdriver.WebElement WebElement, * move the mouse to its
(from, to)
| 936 | * @return {!Actions} a self reference. |
| 937 | */ |
| 938 | dragAndDrop(from, to) { |
| 939 | // Do not require up top to avoid a cycle that breaks static analysis. |
| 940 | const { WebElement } = require('./webdriver') |
| 941 | if (!(to instanceof WebElement) && (!to || typeof to.x !== 'number' || typeof to.y !== 'number')) { |
| 942 | throw new InvalidArgumentError('Invalid drag target; must specify a WebElement or {x, y} offset') |
| 943 | } |
| 944 | |
| 945 | this.move({ origin: from }).press() |
| 946 | if (to instanceof WebElement) { |
| 947 | this.move({ origin: to }) |
| 948 | } else { |
| 949 | this.move({ x: to.x, y: to.y, origin: Origin.POINTER }) |
| 950 | } |
| 951 | return this.release() |
| 952 | } |
| 953 | |
| 954 | /** |
| 955 | * Releases all keys, pointers, and clears internal state. |
no test coverage detected