How to match dynamic class values

Ui.Vision supports XPath locators and thus you can use them for partial class name matching:

In your case the locator would be

  • xpath=//*[starts-with(@class, “css-”)]

  • or maybe xpath=//*[ends-with(@class, “Box-Card”)]

Example macro:

{
  "Name": "dynamic class name",
  "CreationDate": "2023-3-27",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://omayo.blogspot.com/",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "type",
      "Target": "xpath=//*[starts-with(@class, \"classo\")]",
      "Value": "box1",
      "Description": "Partial match of class name"
    },
    {
      "Command": "type",
      "Target": "xpath=(//*[@class=\"classone\"])[2]",
      "Value": "",
      "Description": "second xpath match"
    }
  ]
}

See also Dynamic IDs and How to click a button with a changing ID (partial ID match)?

1 Like