TestProject Forum

Custom element identity path

Hi,
I need to save an element thats in a certain Div (identified by the ID an not the Div).
Here is what the Full XPath currently is:
/html/body/div[2]/section/div/div/div/div[2]/div[4]/div/div[1]/div/div[1]/div[2]/div/label/input

But that div changes depending on if additional panels are added, so I would need to identify this search bar by another way, like id=“CT_Subject”. That id is listed in the div, but I am not sure how to reference it when defining the element to be saved.

for example:

So this what the Full XPath in this example would be:
/html/body/div[2]/section/div/div/div/div[2]/div[4]/div/div[1]/div/div[1]/div[2]/div/label/input

So I need a way to identify that the 7th div contains id=‘CT_Subject’ and that type=‘search’ element is used and not the 4th div search…

Hi @guy

If you are searching for a descendant using it’s ancestor, it would look like:

//div[@id='CT_Subject']//input[@type='search']

If you are searching for an ancestor using it’s descendant, then you can do:

//div[@id='CT_Subject' and descendent::input[@type='search']
1 Like

Rockstar thank you, it works

@marat , would you be able to guide me in this path
image

I need the class=“fa fa-adjust” in the IP Replacement

I’m not sure what exactly are you looking for, but this should probably work:

//i[contains(@class, 'fa-adjust')]