Selector String Parameter
Let's write a CSS selector that accepts a string dynamically. Use the %s
parameter to access run-time information. This parameter is specific to UTAM.
We have a list of soup ingredients, each with a title
attribute. In our test, we want to verify that each list item contains the right ingredient.
In the JSON panel, look at the liByTitle
element on line 11. Its selector uses the %s
variable to get the value of the title
attribute.
"css": "li[title='%s']"
The args
property declares the parameter's name
and type
. For %s
, type
must be string
.
Look at the complied types. The UTAM compiler generated the getLiByTitle(title: string)
method.
The test code can call the generated method to select any item from the list.
Click Run Test.