Relative 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:

Relative Element

Post by webmaster » Wed Feb 27, 2019 9:35 pm

This action selects an element relative to the current element. It takes as an argument a string that represents the relation. The following values can be used to emulate the 4 relative element buttons that are shown when the selection preview panel is expanded:
  • parentElement
  • firstChild
  • previousSibling
  • nextSibling
The following values can also be used, which unlike the relative element buttons, select HTML elements only and skip text nodes:
  • firstElementChild
  • nextElementSibling
  • previousElementSibling
To use this on your project, follow these instructions:

Code: Select all

function (relation)
   Browser.EvalScript
      ·  "return element[argument];"
      ·  relation
   Gather.Text    
Usually, this action will be used right below a selector. Also, the action can be chained when the desired element is not directly related to the original element. For example, suppose a page contains the following HTML:

Code: Select all

<div>
    <h2>Title</h2>
</div>
<p>Content</p>
Also, suppose the project contains a selector called Title that selects the h2 element. The following code could be used to select the p element:

Code: Select all

Select.Title
RelativeElement
   ·  "parentElement"
RelativeElement
   ·  "nextElementSibling"
Note that in this example, if nextSibling was used instead of nextElementSibling, the space between </div> and <p> would be selected.
Juan Soldi
The Helium Scraper Team

Post Reply