Using Selenium, when do we use findElement(...) and findElements(...)?

Experience Level: Junior
Tags: Quality Assurance (QA)Selenium

Answer

Both methods are used to locate an element on a page. Each of them has slightly different behaviour.

Method findElement(...) finds the element matching the criteria. If no element is found, exception is thrown. If one or more elements are found, the first element is returned.

In contrast, the findElements(...) returns the list of matching elements. If no element is found, empty list is returned. If one or more elements are found, they will be present in the returned list?

Related Selenium job interview questions

Comments

No Comments Yet.
Be the first to tell us what you think.
Selenium training
Selenium training

Are you learning Selenium ? Try our test we designed to help you progress faster.

Test yourself

Chat

Oh, the operator is not available. Leave us your comments. We will answer all your questions as soon as possible.

Comments

Anonymous
Καλησπέρα.
Anonymous
the infinteis -3/15 so 1triition / infinet
Anonymous
e
Anonymous
<a href="https://inspirum.pl "
Anonymous
[url]https://inspirum.pl[/url]
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e