* {{> waitForElement }}
(locator, sec = null)
| 2482 | * {{> waitForElement }} |
| 2483 | */ |
| 2484 | async waitForElement(locator, sec = null) { |
| 2485 | const aSec = sec || this.options.waitForTimeoutInSeconds |
| 2486 | |
| 2487 | return this.browser.waitUntil( |
| 2488 | async () => { |
| 2489 | const res = await this._res(locator) |
| 2490 | return res && res.length |
| 2491 | }, |
| 2492 | { |
| 2493 | timeout: aSec * 1000, |
| 2494 | timeoutMsg: `element (${new Locator(locator)}) still not present on page after ${aSec} sec`, |
| 2495 | }, |
| 2496 | ) |
| 2497 | } |
| 2498 | |
| 2499 | /** |
| 2500 | * {{> waitForClickable }} |