I'm using runscope
and am facing a problem with using variables in xpath
.
Imagine I receive a response in the XML form and wish to check if /AllTickets/Ticket[TicketId/text()=12345]/Name/text()
is equal to somename
.
It works just fine, as long as I use hardcoded values
. However, I'd like to be able to pass the value of TicketId
as a variable and cannot do that - apparently the variable ticket_id
(defined earlier in the test) cannot be substituted with its value.
That's what I tried:
/AllTickets/Ticket[TicketId/text()={{ticket_id}}]/Name/text()
or
/AllTickets/Ticket[TicketId/text()=$ticket_id]/Name/text()
There's no problem with the variable itself - if I try to use it in the expected results of the Assertions section, it's substituted just fine.
So, the question is: how can I use variables in xpath part of the XML verification?