Follow Our FB Page << >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

Difference between @findByMethod and @findelement?

Answers were Sorted based on User's Feedback

Difference between @findByMethod and @findelement?..

Answer / elakkiya

Both methods are used to find the webelements.


This is one of the abstract method , should be used to find the single web element.
Return type is single web element.

This is one Annotation in Page factory model and used to locate one or more WebElements using a single criterion.

it has two kind of methods as follows.

• The @FindBys annotation is used in case elements need to match all of the given criteria
• The @FindAll annotation is used in case elements need to match at least one of the given criteria

Is This Answer Correct ?    5 Yes 0 No

Difference between @findByMethod and @findelement?..

Answer / raam

@findby is a testng class,normally we use it in pageclass,
using this we can directly call the webelement


WebElement name;
using name we can easily call the webelement

Is This Answer Correct ?    7 Yes 4 No

Difference between @findByMethod and @findelement?..

Answer / ram

findElement() :

-Find the first element within the current page using the given "locating mechanism".
-Returns a single WebElement.
-Syntax: WebElement findElement(By by).
–will throw "NoSuchElementException" if no matching element found

findElements() :

-Find all elements within the current page using the given "locating mechanism".
-Returns List of WebElements.
-Syntax: java.util.List<WebElement> findElements(By by)
–will return a empty list if no matching elements found and no exception will be thrown

Is This Answer Correct ?    6 Yes 12 No

Post New Answer

More Selenium Interview Questions

Why should selenium be selected as a test program?

0 Answers  

What is assertion in selenium?

0 Answers  

What is the difference between the commit and verify commands?

0 Answers  

Tell me why to choose python over java in selenium?

0 Answers  

How can we get text from a Web Part?

2 Answers  

Give an example of the languages supported by webdriver?

0 Answers  

How to create batch(.bat) file after creating suite from TestNG?Can anyone explain entire process?

2 Answers   Cube Digi,

What are the limitations of selenium?

0 Answers  

Do you know a way to refresh browser by using selenium?

0 Answers  

How to set test case priority in testng?

0 Answers  

What is testng assert and list out some common assertions supported by testng?

0 Answers  

Write the code to right click an element in selenium?

0 Answers