Skip to content

Commit

Permalink
don't fail lazyloading for isVisible and isExisting - closes #2003
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Apr 21, 2017
1 parent 1ae50f1 commit 10adef3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/webdriverio.js
Expand Up @@ -352,9 +352,10 @@ let WebdriverIO = function (args, modifier) {
* otherwise the context would be ignored and a different element could
* selected.
* Ignore this behavior for all waitFor calls as we want to refetch elements
* in case they haven't been found.
* in case they haven't been found. Also not throw an error for isExisting
* and isVisible since they use that information to return their result.
*/
if (!isWaitFor && lastResult.state === 'failure') {
if (!isWaitFor && !name.match(/^is(Existing|Visible)/) && lastResult.state === 'failure') {
let message = lastResult.message

/**
Expand Down
17 changes: 17 additions & 0 deletions test/fixtures/specs/element.spec.js
Expand Up @@ -23,6 +23,23 @@ describe('element as first class citizen', () => {
expect(browser.element('.moreNesting').element('.findme').getText()).to.be.equal('MORE NESTED')
})

it('can lazy load elements but does not fail for isExisting and isVisible', () => {
const elem = $('#notExisting')
expect(elem.isExisting()).to.be.equal(false)
expect(elem.isVisible()).to.be.equal(false)

let message
try {
elem.click()
} catch (e) {
message = e.message
}

expect(message).to.be.equal(
'An element could not be located on the page using the given search parameters ("#notExisting").'
)
})

it('should allow to call waitForExist on elements result', () => {
let element = browser.elements('//div[text()="Sorry, I\'m late!"]')
let start = new Date().getTime()
Expand Down

0 comments on commit 10adef3

Please sign in to comment.