Skip to content

Commit

Permalink
Added NoSuchElementError instead of TimeoutError when chained .find()…
Browse files Browse the repository at this point in the history
… command fails
  • Loading branch information
subhajit20 committed Mar 2, 2024
1 parent f9615e5 commit c82de7a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/api/web-element/scoped-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class ScopedWebElement {
return null;
}

error.name = 'NoSuchElementError';
const narrowedError = createNarrowedError({error, condition, timeout});
Logger.error(narrowedError);

Expand Down Expand Up @@ -323,8 +324,8 @@ class ScopedWebElement {
}

function createNarrowedError({error, condition, timeout}) {
return error.name === 'TimeoutError'
? new Error(`Timed out while waiting for element "${condition}" to be present for ${timeout} milliseconds.`)
return error.name === 'NoSuchElementError'
? new Error('Expected element is not present')
: error;
}

Expand Down

0 comments on commit c82de7a

Please sign in to comment.