Dynamic element ID for "tree" menu

HI @Hanh Tran or who ever that can assist.

i got an issue i need advice on, perhaps someone could help/hint and i be highly appreciative.

this ID tree256489646262835445_2 changes dynamically when my browser app is patched/re-installed

i use it to navigate thru the menu tree and i did try on “contains” in the object properties file using “_2” but this did not work i wonder if i did it wrongly or i should use regex instead?

if it regex how can i detect “test*************_2”?

is there something that i can use to make this work?

//span[count(. | id(“tree256489646262835445_2”)/span[@class=“a-TreeView-toggle”]) = count(id(“tree256489646262835445_2”)/span[@class=“a-TreeView-toggle”])]

2017-12-07_14h04_19.png

2017-12-07_14h15_44.png

@“Bernard Tan Jenn Haur” : Your object property setting are incorrect as you can’t set xpath - contains- [value] to get this dynamic xpath.
I suggest to try with: id-ends with-[‘_2’] and class-equal-[‘a-TreeView-toggle’]

Please see the screenshot for details

2017-12-22 13_48_17.png

Hey @nhi a new year to you. !

Thanks for the idea and share but did not work … so this below is a clear picture of what it need to click on. i tried several way for the “click” to find element “a-TreeView-toggle” which is the only clickable element in the dropdown list.

id=“tree291812186301321712_1” can be dynamically changed to tree291121212121_1 anytime there is an compile.

what was done :

Clickable.

Would i be able to use css or xpath??

Xpath: //ul[contains(@class, ‘a-TreeView-content’)]/li[9]

thanks again

2018-01-15_23h14_34.png

if i were to use direct locators it shows:

Found 1 web elements with id: ‘Object Repository/Extend object/Extend_Objects/A0 - Extend_Home/a0-Custom-Create-Report/Add Table List/span_a-TreeView-toggle’ located by ‘By.xpath: //span[count(. | //[@class = ‘a-TreeView-toggle’]) = count(//[@class = ‘a-TreeView-toggle’])][count(. | id(“tree291812186301321712_9”)/span[@class=“a-TreeView-toggle”]) = count(id(“tree291812186301321712_9”)/span[@class=“a-TreeView-toggle”])]’ in ‘30’ second(s)

selector method by xpath doesnt work as well

.//li[contains(.,’_9’)]//span[@class = ‘a-TreeView-toggle’]

or
//*[ends-with(@id,’_9’)]//span[@class = ‘a-TreeView-toggle’]

its alright . Found the answer :
xpath : //li[9]/span[@class = ‘a-TreeView-toggle’]