Find Element

Premades & Resources to be used with Helium Scraper 3
Post Reply
webmaster
Site Admin
Posts: 491
Joined: Mon Dec 06, 2010 8:39 am
Contact:

Find Element

Post by webmaster » Sat Feb 23, 2019 10:21 pm

Requires version 3.1.8.7 or later

This action finds and selects a matching element given a selector and a text to search for. The following arguments must be given:
  • Selector: A selector that selects the elements in which to run the search. Only the matching element, if any, will be selected. A gatherer can also be given, so that it searches on the gathered value instead of on the element's text.
  • Search Text: The text to search for. Other than the letter case and leading/trailing spaces, the search text must be an exact match.
After the premade has been imported, the selector will be stored in the generated global, and the global will be added to the Wizard menu. If the premade is reused from here, the selector won't be required again. Instead, it can be changed by double clicking the generated global, and any changes will affect every place in which the global is used.

It is recommended to import this premade from the Wizard menu, but it can be manually imported by following these instructions, and then replacing the selector placeholder with a selector, and a gatherer if needed:

Code: Select all

invoke
   function (selector)
      function (searchText)
         Sequence.First
            ·  selector
               as value
               Browser.EvalScript
                  ·  "return argument[0].trim().toUpperCase() == argument[1].trim().toUpperCase() ? [argument[0]] : [];"
                  ·  list
                        ·  value
                        ·  searchText
   ·  [selector]
As an example, suppose I entered FindCategory as the global name, and as the selector/gatherer combination I chose a selector called Categories and the Gather.Text gatherer. Finally, for the Search Text parameter I entered Appliances, such that the resulting code looks like this:

Code: Select all

FindCategory
   ·  "Appliances"
This would find the particular category whose text is Appliances and select it, and if I add an action below, such as a Browser.Navigate action, this action would run on this particular element, which would cause it to navigate through the Appliaces category.

Then, I could reuse it elsewhere from the Wizard menu with a different search text, in order to select any specific category and perhaps navigate through it.
Juan Soldi
The Helium Scraper Team

Post Reply