I am trying to target a user in a list of other users. For example I created an automated test case to create a user named "tester1". I would now like to create a test case that finds and deletes "tester1" within a list of other users. Right now my work around is to find element by xpath which only targets a certain row within the user list. Here is the webpage code that I am working with:
<span class="delete" data-reactid=".0.1.1.0.2.1.0.$usertree.1.0.0.$tester1.0.0.1">
<span class="icon-dash" data-reactid=".0.1.1.0.2.1.0.$usertree.1.0.0.$tester1.0.0.1.0"
></span>
Here is what I have been using for my workaround.
# Finds and clicks minus button to prompt deletion
# Deletes the 4th in the list / to change this, modify the number in the quotes below
element = driver.find_element_by_xpath("//tr[4]/td/div/span/span")
element.click()
# Finds and clicks Delete button
element = driver.find_element_by_xpath("//button[2]")
element.click()
EDIT:
<div class="tree-view_children" data-reactid=".0.1.1.0.2.1.0.$usertree.1"> <table class="ss-table" data-reactide=".0.1.1.0.2.1.0.$usertree.1.0">
<tbody data-reactid=".0.1.1.0.2.1.0.$usertree.1.0.0">
<tr class="user-list-item" data-reactid=".0.1.1.0.2.1.0.$usertree.1.0.0.$tester1">
<td data-reactid=".0.1.1.0.2.1.0.$usertree.1.0.0.$tester1.0">
<div data-reactid=".0.1.1.0.2.1.0.$usertree.1.0.0.$tester1.0.0">
<span class="delete" data-reactid=".0.1.1.0.2.1.0.$usertree.1.0.0.$tester1.0.0.1">
<span class="icon-dash" data- reactid=".0.1.1.0.2.1.0.$usertree.1.0.0.$tester1.0.0.1.0">
</span>