Webtest WebTest GitHub Home

Core Step storeRegEx

Description

This step stores the result of a regular expression into a property. By specifying a particular group of the regular expression it is easily to extract only a subset of a given regular expression.

Parameters

description
Required? no
The description of this test step.
group
Required? no, default is 0 (result of the whole expression)
The group within the regular expression to extract into the specified property.
property
Required? true
The name of the property that shall receive the extracted value.
propertyType
Required? no, default is the "defaultPropertyType" as specified in the "config" element is used.
The type of the property in which to store the retrieve value. Either "ant" or "dynamic".
text
Required? true
The regular expression that shall be evaluated.

Details

The following example extracts a URL from a JavaScript statement associated with an onclick event handler.

storeRegEx
<webtest name="Extract target location from Javascript command">
  <config ... />
  <steps>
    <invoke ... />
    <storeRegEx
      description="Extract target location from javascript command"
      text=".*name=&quot;onClick&quot;.*onclick=&quot; window\.open\('(.*)'\)"
      group="1"
      property="targetLocation" />
    <invoke
      description="Invoke target page specified in the javascript statement"
      url="#{targetLocation}"
      save="targetPage" />
    ...
  </steps>
</webtest>