Variables/xpath¶
Variable in parameter contains XPath expression that returns String object or NULL value. You can use any names that conform to the ECMAScript IdentifierName rules for variables.
In case the node specified in the XPath expression exists on your site, it is returned as shown in the example below.
Code on the desktop site page:
<html>
<head>
<title>Document Title</title>
</head>
</html>
Defining variable in the parameters collection:
{
title: '//title'
}
In this case value of the TITLE tag is returned.
If the specified node does not exist, the variable contains the NULL value.
If multiple nodes are found on the desktop site page, the XPath expression returns concatenated string of their values.
You can use predefined keyword xpath to achieve the same result:
{
title: {
xpath: '//title'
}
}
So you can see that the definition without predefined keyword is shorter. But it is necessary to use the xpath keyword if you are going to define extra keywords, for example, parameters or get.
Note
You can generate XPath statements automatically to obtain 100% correct value easily.