Difference between @findByMethod and @findelement?
Answers were Sorted based on User's Feedback
Answer / elakkiya
Both methods are used to find the webelements.
findelement:
-------------------
This is one of the abstract method , should be used to find the single web element.
Return type is single web element.
@Findby:
--------------
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 |
Answer / raam
@findby is a testng class,normally we use it in pageclass,
using this we can directly call the webelement
ex
:
----------------------
@findby(driver.findElement(By.xpath(!@#$%%))
WebElement name;
--------------------------
using name we can easily call the webelement
| Is This Answer Correct ? | 7 Yes | 4 No |
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 | 13 No |
What is the purpose of the getoptions() method?
What are the prerequisites to run selenium webdriver?
How you can find broken images in a page using selenium web driver?
What are the advantages of selenium grid?
How do you send enter/tab keys in webdriver?
I am not able to use "style" attribute to locate element with ie browser?
What distinguishes between an absolute and relative url in side?
Tell me can we use selenium rc for tests driving on two different browsers on one operating system without selenium grid?
How is testng better than junit?
How many types of waits in selenium?
What are the main advantages of selenium?
Can you explain the framework which you have used in your selenium project?