A question on how the XPath Expression works

153 views
Skip to first unread message

Wasabi

unread,
Aug 13, 2022, 8:04:24 AM8/13/22
to Automate
I have a variable "row" set to a number generated by the random(number) function. I'm trying to put that variable inside an xpath expression:

"//*[contains(@layout=' " + row + " ')]"

However, no events are running when this block is reached. Is it because the variable type is still in a number format (int)? If so, how does one convert the type into string. Thanks in advanced.

david....@gmail.com

unread,
Aug 13, 2022, 8:39:08 AM8/13/22
to Automate
You can use string interpolation :
"//*[contains(@layout='{row}')]"

Henrik "The Developer" Lindqvist

unread,
Aug 13, 2022, 1:32:19 PM8/13/22
to Automate
XML attributes, e.g. @layout, are always text.

Your XPath probably doesn't match any node because there's @layout attribute, see:
Reply all
Reply to author
Forward
0 new messages