English|Deutsch
Subscribe Ranorex Announcements Feed Ranorex LinkedIn Ranorex twitter Ranorex Facebook

RanoreXPath

RanoreXPath allows easy identification/searching/filtering of web elements and navigation in web documents. RanoreXPath is modeled on W3C XPath.

You can find several samples on the web testing sample page which describe how to use RanoreXPath.

RanoreXPath examples

//tr[@class='odd' and position()='1']
every first table row with class name 'odd'
//tr/*
all elements in every table row
/body/h1[1]
first h1 element in the body
//a[@text()='link' or @title='title']
every link with link text 'link' or title 'title'
//div[@id='content']/a
all links in the div element with the id 'content'
./tr[@class='odd']
all tr items with class name 'odd' relative to the current element
//a[text()!='link']
all links with the link text not equal to 'link'
//tr[@background-color='#eee']
all tr items with style attribute background-color '#eee'

RanoreXPath axes

/body/div
absolute
//div
all div elements in the tree, beginning from root
./div
relative
.//div
all div elements in the tree, beginning from current element
../div
all div elements from parent

RanoreXPath with regular expression

//div[@id~'sample[0-9]']
matches following div elements: sample0, sample1, ... sample9
//div[@id~'^sample.*']
matches all elements starting with sample
//div[@id~'gr(a|e)y']
matches gray or grey


You can use the following special characters in a regular expression:

CharacterDescription
.The dot will match any single character. For example „Sample.“ matches „Sample1“, „Samplex“, etc.
$The dollar sign will match the end of the string. The expression "abc$" will match the sub-string "abc" only if it is at the end of the string.
|The alternation character allows either expression on its side to match the target string. The expression "gr(a|e)y" can match „gray“ or „grey“.
*The asterix indicates that the character to the left of the asterix in the expression should match 0 or more times. For example „go*gle“ matches ggle, gogle, google, gooogle, etc.
+The plus is similar to asterix but there must be at least one match of the character to the left of the + sign in the expression.For example „go+gle“ matches gogle, google, gooogle, etc.
?The question mark (?) matches the character to its left 0 or 1 times. For example, „colou?r“ matches both color and colour.
^Beginning of the string. The expression "^A" will match an A only at the beginning of the string.
()The parenthesis affects the order of pattern evaluation.
[]Brackets ([ and ]) enclosing a set of characters indicate that any of the enclosed characters may match the target character.
[^0-9]The caret immediately following the left-bracket ([) has a different meaning. It is used to exclude the remaining characters within brackets from matching the target string. The expression "[^0-9]" indicates that the target character must not be a digit.