Reputation: 185
enter image description hereOn a page I have a row, I wanted to delete the row based on the row data, i.e if I have multiple rows, I can delete the row based on the row (cell) data
I am able to read the data, also I am able to identify the delete button separately.
But the challenge is, if I have more than one row then I get more than 1 matching for delete button.
So I wanted to delete the row based on the cell data.
When I try with parent<<>> child node logic i couldn't able to find the delete button based on the row data.
below are the xpaths which i tried, can someone pls suggest me how to get correct xpath
.
xpath
to find row data:
//div[@class='ui-grid-draggable-row ng-scope ng-isolate-scope']/div/div[contains(@title,'ART_Location')]
xpath
to find delete button:
//div[@class='ui-grid-draggable-row ng-scope ng-isolate-scope']/div/div/button[@class='delete-data-collectors-monitor']
if i combine both xpaths (row data with delete)
xpath= //div[@class='ui-grid-draggable-row ng-scope ng-isolate-scope']/div/div[contains(@title,'ART_Location')]/../button[@class='delete-data-collectors-monitor']
here i am not getting the delete button identified, pls suggest.
Upvotes: 0
Views: 677
Reputation: 761
Try using below xpath
.
.//div[text()='ART_Location']/../..//button[@class='<class name of the button>']
If your delete button is in the last column, then use the below xpath
:
.//div[text()='ART_Location']/../div[last()]/div/button[@class='<class name of the button>']
If your delete button is present at a particular position then use below xpath
:
.//div[text()='ART_Location']/../following-sibling::div[position()=<position number from the ART_Location div>]/div/button
Hope this helps.
Upvotes: 1