How Can I expand the list and choose dynamic value.
<p>I'm trying to find out the solution how to get the target of <strong>Add New</strong> from <strong>Prod2</strong> from the code below.</p>

<p>To get this target at first I have to click on <strong>ptv-icon ptv-collapse-icon</strong>. This is possible using XPATH but each time when I run the script xpath is changing.</p>

<p>Does it possible to use any method to localize <strong>Add New</strong> directly.</p>

<p>Another problem is that: <strong>Add New</strong> element is only visible after I will click on <strong>ptv-icon ptv-collapse-icon</strong>. </p>

<pre><code>&lt;li class="ptv-listitem" data-id="1"&gt;
&lt;div class="ptv-item"&gt;
&lt;span class="ptv-icon ptv-expand-icon"&gt;&lt;/span&gt;
&lt;span class="ptv-text"&gt;
&lt;span class="tree-text"&gt;Prod1&lt;/span&gt;
&lt;span class="tree-counts"&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li class="ptv-listitem" data-id="2"&gt;
&lt;div class="ptv-item"&gt;
&lt;span class="ptv-icon ptv-collapse-icon"&gt;&lt;/span&gt;
&lt;span class="ptv-text ptv-selected"&gt;
&lt;span class="tree-text"&gt;Prod2&lt;/span&gt;
&lt;span class="tree-counts"&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/div&gt;
&lt;ul class="ptv-list ptx-expanded"&gt;
&lt;li class="ptv-listitem" data-id="-1"&gt;
&lt;div class="ptv-item"&gt;
&lt;span class="ptv-text"&gt;
&lt;span class="tree-text"&gt;**Add New**&lt;/span&gt;
&lt;span class="tree-counts"&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li
</code></pre>