* Run a function in the browser with this element as the first argument. * @param {Function} fn Browser-side function. Receives the element, then extra args. * @param {...any} args Additional arguments passed to the function * @returns {Promise } Value returned by fn
(fn, ...args)
| 266 | * @returns {Promise<any>} Value returned by fn |
| 267 | */ |
| 268 | async evaluate(fn, ...args) { |
| 269 | switch (this.helperType) { |
| 270 | case 'playwright': |
| 271 | case 'puppeteer': |
| 272 | return this.element.evaluate(fn, ...args) |
| 273 | case 'webdriver': |
| 274 | return this.helper.executeScript(fn, this.element, ...args) |
| 275 | default: |
| 276 | throw new Error(`Unsupported helper type: ${this.helperType}`) |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * Focus the element. |
no test coverage detected