* {{> scrollTo }}
(locator, offsetX = 0, offsetY = 0)
| 1672 | * {{> scrollTo }} |
| 1673 | */ |
| 1674 | async scrollTo(locator, offsetX = 0, offsetY = 0) { |
| 1675 | if (typeof locator === 'number' && typeof offsetX === 'number') { |
| 1676 | offsetY = offsetX |
| 1677 | offsetX = locator |
| 1678 | locator = null |
| 1679 | } |
| 1680 | |
| 1681 | if (locator) { |
| 1682 | const el = await this._locateElement(locator) |
| 1683 | assertElementExists(el, locator, 'Element') |
| 1684 | await el.scrollIntoViewIfNeeded() |
| 1685 | const elementCoordinates = await clickablePoint(el) |
| 1686 | await this.executeScript((offsetX, offsetY) => window.scrollBy(offsetX, offsetY), { |
| 1687 | offsetX: elementCoordinates.x + offsetX, |
| 1688 | offsetY: elementCoordinates.y + offsetY, |
| 1689 | }) |
| 1690 | } else { |
| 1691 | await this.executeScript(({ offsetX, offsetY }) => window.scrollTo(offsetX, offsetY), { offsetX, offsetY }) |
| 1692 | } |
| 1693 | return this._waitForAction() |
| 1694 | } |
| 1695 | |
| 1696 | /** |
| 1697 | * {{> seeInTitle }} |
no test coverage detected