I'm new to selenium and HTML. I want to perform click operation for the elements "Users" and "Admins" as one after another. Below mentioned is the HTML code, unfortunately I can't modify it.
<ul id="nav">
<li class="">
<a class="mainmenu" title="List of Users" menuid="nav_0">
<span class="title">Users</span>
<span class="arrow"/>
</a>
<ul class="sub-menu">
<li>
<a class="mainmenu" title="List of Admins" menuid="nav_0-sub_0">Admins</a>
</li>
</ul>
</li>
<li class="">
<a class="mainmenu" title="List of Contents" menuid="nav_1">
<span class="title">Contents</span>
</a>
</li>
<li class="">
<a class="mainmenu" title="Repos" menuid="nav_2">
<span class="title">Repository</span>
</a>
</li>
I have used XPath like this:
.//*[@id='nav']/li[1]/a[contains(@title, 'List of Users']
Any other ways to get the element like matching the text value? Because the list elements order is dynamic, so the current position of the element "Users"(li[1]
) might get change later.