Question

Clicking on a button in a table row, based on another cell in the row

  • 4 January 2022
  • 2 replies
  • 46 views

Badge +6

Edit: Forgot to mention this is on A360 Cloud

 

I am curious if anyone has had to do something similar. I am working on a bot that at one point has to select a specific row in a table and then click a "Review" button. The table looks like this:

 

table 

For each row, the App ID will be unique. I need to click on the row with a specific AppID, and then click the Review button for that particular row. Just curious if there is an easy way to do it.

 

I thought of using javascript to cycle through all rows, something like this:

 

var n1 = document.getElementById("AppTable").rows.length;

 

for(i=0;i<n1;i++) {

if(document.getElementById("AppTable").rows[i].cells.item(0).innerText = "AppIDXYZ"){

document.getElementById("AppTable").rows[i].cells.item(7).click();

}

}

 

But it is not working for me; I get the innerText but it states click is not a viable option for that control. Also this would be an issue if the item I want is on page 3 or 4 of the table, as the javascript only returns the items on the visible page. I am hoping there is an easier way to do this natively with AA.


2 replies

Userlevel 3
Badge +7

Hi @Jeremiah Logan​ ,

 

You can use the Recorder: Capture Action to achieve this.

 

Check everything off except for the DOMXpath and craft a Xpath after studying the DOM.

Right click on any of the Review Button and create an Xpath for that.

 

You can then use a Counter Variable to cycle through each line until it meets the condition you are looking for. The alternative would be to create two xpaths - one to detect the appid and the other for the review button.

 

say for example, that the AppID Xpath is //tr[@id='appIDAttributeValue'] and the Review button for that particular line is (//td[@id='ReviewBtnAttribute'])[3]

 

You have to find a way to combine both xpaths such that the Xpath recieves the AppId you want it to search for as input:

 

//tr[@id=$AppID$]/following-sibling::td[@id='ReviewBtnAttribute']

 

Might seem a little complicated at first, especially if you are new to Xpaths.

Here is a website which covers the basics, I hope you find it resourceful.

 

If this website is public, I could maybe have a look at it aswell.

 

Kind Regards,

Ashwin A.K

Badge +6

Thanks for the suggestion. I have done some with using the XPath in Selenium in the past; I will give this a try.

Reply