Herbie Logo

Keywords with Variable Playground

Instructions

To add a keyword with a variable in the Herbie extension, follow these steps:

  1. Navigate to the Keywords tab in the Herbie extension.
  2. In the Enter keyword field, type your desired keyword, e.g., DynamicLink.
  3. In the Enter XPath field, type the XPath of the element with a variable, e.g., //a[contains(text(),"{$}")].
  4. Check the Has Variable checkbox to indicate that this XPath contains a variable.
  5. Click the Add Keyword button to save the keyword.
  6. The keyword will now appear under the Global Keywords section.
  7. To use the added keyword in your Herbie script, navigate back to the Herbie tab and type the following:
  8. click on "Click me" 'DynamicLink'

Use Keyword with Variable in Herbie Script

After adding the keyword, use it in the script as shown below:

click on "Click me" 'DynamicLink'

This will replace the variable in the XPath with "Click me" and simulate a click action on the matching element.

Click Me