Relative Element
Posted: 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:
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:
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:
Note that in this example, if nextSibling was used instead of nextElementSibling, the space between </div> and <p> would be selected.
- parentElement
- firstChild
- previousSibling
- nextSibling
- firstElementChild
- nextElementSibling
- previousElementSibling
Code: Select all
function (relation)
Browser.EvalScript
· "return element[argument];"
· relation
Gather.Text
Code: Select all
<div>
<h2>Title</h2>
</div>
<p>Content</p>
Code: Select all
Select.Title
RelativeElement
· "parentElement"
RelativeElement
· "nextElementSibling"