findElement vs element #2815
Replies: 2 comments
-
For your use case, use: let result = await browser.findElements({
selector: '<your_selector>',
suppressNotFoundErrors: true
}) |
Beta Was this translation helpful? Give feedback.
-
Hi, browser.element('css selector', 'selectorname', function (visible) { I think this is what you were asking. |
Beta Was this translation helpful? Give feedback.
-
Describe
What is the main difference between .element and .findElement API ?
I have notice in my project that if If use .element(someCSSselector) and element does not really exists,
nighwatch returned me only information:
{ status: -1, state: '', code: '', value: { message: 'no such element: Unable to locate element: {"method":"css selector","selector":"#authorization-code"}', error: [ ' (Session info: chrome=91.0.4472.114)', ' (Driver info: chromedriver=91.0.4472.101 (af52a90bf87030dd1523486a1cd3ae25c5d76c9b-refs/branch-heads/4472@{#1462}),platform=Windows NT 10.0.19042 x86_64)' ] }, errorStatus: 7, error: 'An element could not be located on the page using the given search parameters. – no such element: Unable to locate eleme...', httpStatusCode: 200 }
and the test will go on.
But when a I use findElement instead of .element I got an error:
{"sessionId":"jhkhkkljkkkkkkk9c2a","status":0,"value":[]} at Object.module.exports.command (tests\commands\AuthorizeTransaction.js:41:8) at processImmediate (internal/timers.js:461:21) { status: -1, value: { error: 'An error occurred while running .findElement() command on <#second-authorization-code>: ', message: 'An error occurred while running .findElement() command on <#second-authorization-code>: ', stack: 'Error\n' + ' at Object.module.exports.command ('PATH' + ' at processImmediate (internal/timers.js:461:21)' } }
Environment
nightwatch --version
Is it bug or feature ?
I need it into my test case when I have to check if second authorize code will appear or not.
Beta Was this translation helpful? Give feedback.
All reactions