Issue
Following code I need to identify third li element(user list). How I co do using selenium?
I have tried using,
String usertype= //td[text()='product']
String usersubtype= li[@class='user-list dropbutton-action secondary-action']
String adduser = usertype +"following-sibling::td//" +usersubtype+"/a"
I must use following method. Because my code usertype and usersubtype values coming from different place
(above strings just for reference)
But it could not work out. Please help me to identify the third li element(user list)
I need to identify following element in the code
<li class="content-list dropbutton-action secondary-action"><a href="/admin/structure/eck/entity/product">User list</a></li>
Below is my code snippet:
<tr class="even">
<td>product</td>
<td>product</td>
<td>
<div class="code-wrapper dropbutton-multiple">
<div class="dropbutton-widget">
<ul class="dropbutton">
<li class="user dropbutton-action"><a href="/user/userlist/abc/productcontent/add">Add User</a></li>
<li class="dropbutton-toggle"><button type="button"><span class="dropbutton-arrow"><span class="visually-hidden">List actions</span></span></button></li>
<li class="user-list dropbutton-action secondary-action"><a href="/user/userlist/abc/productproduct">User list</a></li>
<li class="user-list dropbutton-action secondary-action"><a href="/user/userlist/abc/productproduct/types">Test list</a></li>
<li class="edit dropbutton-action"><a href="/user/userlist/abc/productmanage/product?destination=/admin/structure/eck/entity_type">Edit</a></li>
<li class="delete dropbutton-action"><a href="/user/userlist/abc/productmanage/product/delete?destination=/admin/structure/eck/entity_type">Delete</a></li>
</ul>
</div>
</div>
</td>
Solution
The issue with your locator is that it is incorrect. The double slash is missing from the following-sibling::
.
Try changing:
//td[text()='product']following-sibling::td//li[@class='user-list dropbutton-action secondary-action']
To
//td[text()='product']//following-sibling::td//li[@class='user-list dropbutton-action secondary-action']/a
Complete code:
String usertype= //td[text()='product']
String usersubtype= li[@class='user-list dropbutton-action secondary-action']
String adduser = usertype +"//following-sibling::td//" +usersubtype+"/a"
Answered By - Abhishek Dhoundiyal
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.