* {{> scrollTo }}
(locator, offsetX = 0, offsetY = 0)
| 918 | * {{> scrollTo }} |
| 919 | */ |
| 920 | async scrollTo(locator, offsetX = 0, offsetY = 0) { |
| 921 | if (typeof locator === 'number' && typeof offsetX === 'number') { |
| 922 | offsetY = offsetX |
| 923 | offsetX = locator |
| 924 | locator = null |
| 925 | } |
| 926 | |
| 927 | if (locator) { |
| 928 | const el = await this._locateElement(locator) |
| 929 | if (!el) { |
| 930 | throw new ElementNotFound(locator, 'Element to scroll into view') |
| 931 | } |
| 932 | await el.evaluate(el => el.scrollIntoView()) |
| 933 | const elementCoordinates = await getClickablePoint(el) |
| 934 | await this.executeScript((x, y) => window.scrollBy(x, y), elementCoordinates.x + offsetX, elementCoordinates.y + offsetY) |
| 935 | } else { |
| 936 | await this.executeScript((x, y) => window.scrollTo(x, y), offsetX, offsetY) |
| 937 | } |
| 938 | return this._waitForAction() |
| 939 | } |
| 940 | |
| 941 | /** |
| 942 | * {{> seeInTitle }} |
no test coverage detected