Hi,
I am automating a scenario wherein I have a select a row from the table and I am selecting using the innertext as it is present inside the span element
(Please refer to the screenshot attached)
And then I have to click on the delete button for the same row
But every time the image which I have to click will be different everytime so we cannot hardcode it on the basis of row number, that's the reason I am selecting the row based on the innertext of the row because the name of the image will always be same
So, basically I am looking for a solution like whatever row I am selecting using innertext the subsequent delete button should be clicked for the same row
Please refer to the screenshot attached and the snapshot
Please let me know if I did not made my point my clear
Select a row from the table and then click t he subsequent delete button from the same row
Select a row from the table and then click t he subsequent delete button from the same row
- Attachments
-
- TableRootSnapshot.rxsnp
- (119.43 KiB) Downloaded 16 times
-
- DeleteRow.png (10.86 KiB) Viewed 793 times
Re: Select a row from the table and then click t he subsequent delete button from the same row
Hi,
The xpath you are looking for looks like this:
All you need to do is to replace 'Automation.jpg' with variable of your choice, ideally filled with data connector.
I would also suggest you to watch this webinar about mastering xpaths:
https://www.ranorex.com/automated-testi ... norexpath/
And make sure to read and understand these user guide chapters:
https://www.ranorex.com/help/latest/ran ... roduction/
https://www.ranorex.com/help/latest/ran ... roduction/
Understanding Ranorex xpaths is the most essential part of Ranorex knowledge. Without deep understanding of xpaths, how to construct them and how to use relationship operators, your Ranorex time will be more a guess work. So give it a time to learn it and understand it
Good luck!
The xpath you are looking for looks like this:
Code: Select all
/dom[@domain='dashboard.eu-iport.nielsen-iwatch.com.aws-w-np.nielsencsp.com']//div[@class='edit-view-container']//div[@class='left-panel-container']//div[@class='mj-treegrid-container']//table/tbody//div[@class~'mj-text']/span[@innertext='Automation.jpg']/ancestor::tr//a[@class='delete']
I would also suggest you to watch this webinar about mastering xpaths:
https://www.ranorex.com/automated-testi ... norexpath/
And make sure to read and understand these user guide chapters:
https://www.ranorex.com/help/latest/ran ... roduction/
https://www.ranorex.com/help/latest/ran ... roduction/
Understanding Ranorex xpaths is the most essential part of Ranorex knowledge. Without deep understanding of xpaths, how to construct them and how to use relationship operators, your Ranorex time will be more a guess work. So give it a time to learn it and understand it

Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: Select a row from the table and then click t he subsequent delete button from the same row
Hi,
Thanks a lot for this information,
It really helped,
Just out of curiosity I am asking, in case if there are two a[@class='delete'] a tags in the same row then it will click on the first ancestor how to make it click on the second ancestor?
Thanks for sharing the recordings also, I will definitely go through it to improve my xpath designing skills
Thanks a lot for this information,
It really helped,
Just out of curiosity I am asking, in case if there are two a[@class='delete'] a tags in the same row then it will click on the first ancestor how to make it click on the second ancestor?
Thanks for sharing the recordings also, I will definitely go through it to improve my xpath designing skills
Re: Select a row from the table and then click t he subsequent delete button from the same row
Hi,
In case there are two a[@class='delete'] tags in the same row, and you wan to click just the second one, you have to add an index at the end of A tag, like this:
https://www.ranorex.com/help/latest/han ... oryelement
In your case, the code should look like this:
Where the elementFromRepo argument should be assigned with repo element, pointing to the xpath I provided before (without index at the end of xpath). Hope this helps?
In case there are two a[@class='delete'] tags in the same row, and you wan to click just the second one, you have to add an index at the end of A tag, like this:
Eventually, you can use this, to tell Ranorex to click the 'last one' in the list of returned elements (just in case there may be three, four, or 'n' elements and you want to click the LAST one):./ancestor::tr//a[@class='delete'][2]
However, if you want to click both first and second delete A tag, you will have to construct some code for this. For an example of code, which creates list of adapters from repo info element, and which click each found element, check this paragraph:./ancestor::tr//a[@class='delete'][-1]
https://www.ranorex.com/help/latest/han ... oryelement
In your case, the code should look like this:
Code: Select all
public void ClickAllDeleteButtonsInTheSameRow(RepoItemInfo elementFromRepo)
{
// Create a list of adapters using the "Info" object
IList<Ranorex.ATag> buttonList = elementFromRepo.CreateAdapters<Ranorex.ATag>();
// Move the mouse pointer to each button of the list and click it
foreach (Ranorex.ATag button in buttonList )
{
button.Click();
}
}
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration