KevinGrandon/ghostjs

Consider wrapping waitForElement* methods into a single find() call

Opened this issue · 0 comments

Multiple waitForElement* calls could be wrapped into a single find call. Currently the most common use case is to wait for an element to be in the DOM and visible, so optimize on find() handling that case.

E.g., all of these methods:

await findElement(selector)
await waitForElement(selector)
await waitForElementVisible(selector)
await waitForElementNotVisible(selector)

Could probably be transitioned into something like:

await find(selector, {checkVisible: false, checkPresent: false})
await find(selector, {checkVisible: false})
await find(selector)
await find(selector, {checkNotVisible: true})

Find signature:

async find(selector:String, options:{checkVisible:boolean=true, checkPresent:boolean=true, checkNotVisible:boolean=false})