Advanced Selector

The Advanced Selector supports more complex methods for selecting an element from the page. It should be used when the standard methods (e.g. Dom Path or Class Path) are not adequate. Please note this is an advanced topic and if you need assistance using it please contact support using the help menu inside WebGet.

The Advanced Selector is a Json (JavaScript Object Notation) string. It consist of a series of property names and values. For example: {"Name": "James", "Age": 21}

Your Advanced Selector must contain one of the following properties. These properties will return one or more elements from the page:
  • DomPath: This is similar to the Dom Path field in WebGet except it can return multiple items. For the full list of options available see this xPath document.
  • DomPathList: A list of multiple Dom Path items. If the DomPath property is specified, DomPathList is ignored.
  • CssSelector: A Css (Cascading Sytle Sheet) selector expression. For the list of options available in a Css selector see this Reference guide.

Then you can filter the elements selected above by the following optional parameters:
  • Text: Loops over all elements trying to match the text specified to the text on the element. The element text doesn't need to be a precise match, instead it must contain the text specified.
  • Regex: Loops over all elements trying to match the element text with the regular expression specified. For more information see this Regex tutorial
  • Class: Loops over all elements trying to match the element's Css class name with the class specified.
  • Position: Returns the element specified by this position number after all other filters have been applied. E.g. 1 for 1st, 2 for 2nd, etc. If this Position parameter isn't specified WebGet will use 1 (the first element). Specify negative numbers to return the position from the back, e.g -1 for last, -2 for second last, etc.

Examples:
  • {"DomPath": "/HTML[1]/BODY[1]/DIV[1]/A", "Text": "Next"}
    Finds the first Anchor (A) element in the dom path specified where the text contains "Next"
  • {"DomPath": "/HTML[1]/BODY[1]/DIV[1]/A", "Class": "btn", "Position": -1}
    Finds the last Anchor (A) element that has a Css class name of "btn" in the dom path specified
  • {"DomPathList": ["/DIV[1]/P[1]/SPAN[1]", "/P[1]/SPAN[1]"]}
    Finds the first element matched by either of the Dom Path's specified