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.

Hi everyone,
I am learning automation using katalon. I have this situation:
I have a form with 3 dropdpwns: state, department, category. Depending on the state, the department would be show, category depend on department. In each field you can tipping, and the system shows the item of the dropdown and you can select it.
The problem is: the Id of each field is dynamic. How can write my test case.

Dropdowns: state, department, category
Bottom: Acept

Thank you in advance

@daimilamoru2018

Please do not extend an 4 years old post.
Please make a new post for your issue.

In the new post we would require more information. Have a look at the following guidance.