I am currently trying to find a solution for extracting the target of Add New from Prod2 in the provided code snippet.
In order to retrieve this target, I need to first click on ptv-icon ptv-collapse-icon. The challenge lies in the fact that the XPath changes every time the script is executed.
Is there a method available to directly locate and extract the target Add New without relying on the changing XPath?
Another issue I encountered is that the element Add New only becomes visible once I have clicked on ptv-icon ptv-collapse-icon.
<li class="ptv-listitem" data-id="1">
<div class="ptv-item">
<span class="ptv-icon ptv-expand-icon"></span>
<span class="ptv-text">
<span class="tree-text">Prod1</span>
<span class="tree-counts"></span>
</span>
</div>
</li>
<li class="ptv-listitem" data-id="2">
<div class="ptv-item">
<span class="ptv-icon ptv-collapse-icon"></span>
<span class="ptv-text ptv-selected">
<span class="tree-text">Prod2</span>
<span class="tree-counts"></span>
</span>
</div>
<ul class="ptv-list ptx-expanded">
<li class="ptv-listitem" data-id="-1">
<div class="ptv-item">
<span class="ptv-text">
<span class="tree-text">**Add New**</span>
<span class="tree-counts"></span>
</span>
</div>
</li>
</ul>
</li