There are multiple cases in automation where you would like to fetch multiple elements. In such cases, you can use any of the three APIs – _collect, _collectAttributes and _collectElementsInfo.Let us see each API in detail._collect:This API returns an array of element stubs of all elements of type apiType matching the identifier within relations.Syntax:_collect($apiType, $identifier[, $relations …])$apiTypestringtype of elements to collect. Eg. “_link”, “_button”, “/text/” etc.$identifierstring|intSahi Identifier. Can also be just an index.$relations …relations optionalRelations like _in, _near etc.The next API to check out is _collectAttributesThis returns an array of element attributes of all elements of type apiType matching the identifier within relations.Syntax:_collectAttributes($apiType, $identifier, $attribute[, $relations …])$apiTypestringtype of elements to collect. Eg. “_link”, “_button”, “/text/” etc.$identifierstring|intSahi Identifier. Can also be just an index.$attributeattribute|functionattribute or function.$relations …relations optionalRelations like _in, _near etc.This can fetchThis API can fetch
- a simple attribute from multiple elements
- one of the few simple attributes from multiple elements
- some synthesized/processed values from multiple elements by executing
- an inline function for each element
- a defined function for each element
- nested functions
The third API to note is _collectElementsInfoThis API returns array of Accessor Info object of all elements of type apiType within relations.Syntax:_collectElementsInfo($apiType[, $relations …])$apiTypestringType of elements to collect. Can be regular expression. Eg. “_link”, “_button”, “/text/” etc.$relations …relations optionalRelations like _in, _near etc.To know more about Fetch APIs, please refer this link: https://sahipro.com/docs/sahi-apis/fetch-apis.htmlFeel free to write your questions to support@sahipro.com
