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:
{
"api": "1.0.2.1",
"parameters": {
"relation": {
"caption": "Relation",
"type": "options",
"options": [
"parentElement",
"firstChild",
"nextSibling",
"previousSibling",
"firstElementChild",
"nextElementSibling",
"previousElementSibling"
],
"default": "firstChild"
}
}
}
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.