Arilay
Arilay

Reputation: 47

KARATE UI: How to pass a dynamic value to a locator and assertions?

Api returns a confirmationNumber, which i'm storing in a variable then using that confirmationNumber to click and assert on the UI page.

//some ui login steps are here

Then input('#paymentNum',confirmationNumber) //--successfully entered confirmationNumber

And assert exists('{div}confirmationNumber'). //--not successful. not able to read the stored value

And click('{a}confirmationNumber') //--not successful. not able to read the stored value

Please help Thank you

Upvotes: 1

Views: 978

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58088

Easy. Think of anything within the ( and ) as pure JavaScript. Also please note the extra exists, hmm maybe I should re-design that part of the API - and thanks for asking this question ! https://github.com/intuit/karate/issues/1148

# this is how to use exists() right now, but I have decided to change this !
And assert exists('{div}' + confirmationNumber).exists
And click('{a}' + confirmationNumber)

Upvotes: 1

Related Questions