Selecting element with dynamic IDs : Xpath selector using class attribute

Hi folks,

Am new to Katalon and am creating my first test cases. Problem with our application is that all tag ID attributes change each time the page is loaded. I have no control over this but I can add a css class to the div that contains my desired input tag.

How can I make an Xpath selector that says, "Select the input node that is found as a descendant (2 levels) of a div node that has the class "k-text_var’ "? With the understanding that it is not the only class for that div node, for example class=“form-group k-text_var”. There could be two, three, or four other classes in there too.

Example:

   <span data-field="text_var" style="">Text var</span>
  <input id="vzn5b3649fe4f87a8\_48696730" name="vzn5b3649fe4f87a8\_48696730" value="" maxlength="255" class="form-control" style="" null="" type="text">

Hi Curtis

I don’t do xpath, but here’s the CSS you need according to your spec:

div.k-text_var input

If there is more than one div with that class and more than one input, you will get multiple input controls returned.

CSS Selector is natural choice, of cource.

Here is XPath alternative:

//div[contains(@class,'k-text_var']//input

Yes, I see. Perfect. Thanks Russ and Kazurayam.