Webtest WebTest GitHub Home

Core Step verifyXPath

Description

This step verifies that an XPath expression is true or has a certain value. Useful for XML and HTML pages.

This is one of the most powerful verification features of Canoo WebTest. You may want to use XPath Explorer for finding appropriate expressions.

Parameters

description
Required? no
The description of this test step.
regex
Required? no, default is 'false'
Specifies whether the text value represents a regular expression.
text
Required? no
The expected text value of the xpath evaluation. If omitted the step checks that the result is not the boolean false and not empty.
xpath
Required? true
Specifies the XPath expression to evaluate.

Details

<target name="testXPath">
  <webtest name="xpath" >
    &sharedConfiguration;
    <steps>
      ..
      <verifyXPath description="simple match"
        xpath="/html/head/title"/>
      <verifyXPath description="more complicated match"
        xpath="//img[@src='seibertec.gif']"/>
      <verifyXPath description="simple match with value"
        xpath="/html/head/title"
        text="Canoo WebTest"/>
      <verifyXPath description="simple boolean expression"
        xpath="1 &gt; 0"/>
    </steps>
  </webtest>
</target>

See also: the storeXPath and selectForm steps.