|
Answer» The Protractor documentation mentions the distinction in most simple way:–
Element Finder:
- The Element Finder simply represents a single element of an ElementArrayFinder (and is more like a CONVENIENCE object). As a result, anything that can be done with an Element Finder can also be done using an ElementArrayFinder.
- The Element Finder can be treated as a Web Element for most PURPOSES; in PARTICULAR, you may perform actions (i.e. click, get Text) on them as you would a Web Element. Once an action is performed on an Element Finder, the latest result from the chain can be accessed using the then method. UNLIKE a Web Element, an Element Finder will wait for angular to settle before performing finds or actions.
Element Array Finder:
- ElementArrayFinder is used for operations on an array of elements (as opposed to a single element).
- The ElementArrayFinder is used to set up a chain of conditions that identify an array of elements. In particular, you can call all (locator) and filter (filterFn) to return a new ElementArrayFinder modified by the conditions, and you can call get(index) to return a single Element Finder at position ‘index’.
- Similar to jquery, ElementArrayFinder will search all branches of the DOM to find the elements that satisfy the conditions (i.e. all, filter, get). However, an ElementArrayFinder will not ACTUALLY retrieve the elements until an action is called, which means it can be set up in helper files (i.e. page objects) before the page is available, and reused as the page changes.
- SO, basically, if you’ve ever worked with Selenium in the past, you’d recognise that it is nothing but the difference between Find Element and Find Elements.
The Protractor documentation mentions the distinction in most simple way:– Element Finder: Element Array Finder:
|