Having trouble isolating a button on a web page

It’s a list of users within a company. Companies can of course have different numbers of users. Each user has an “Actions” button next to it that opens a hidden menu with actions like deactivate, delete, etc.

The issue is there’s nothing unique about the Actions button. The Delete link always exists within each submenu and contains the user ID and the word “deleteUser” within the CSS class. I have the user ID and need to click the user’s Actions button then click Delete. What I did was find the Delete button using wildcards in the selector. “CurrentUserID” is just a variable with the user ID from the current row in the datatable I’m looping through.

<webctrl class=’*deleteUser*" + CurrentUserID + "*’ tag=‘button’ />

The Delete button is not a child of the Actions button, both are children of the same DIV, so I used the Get Ancestor activity to find that DIV. Get Ancestor is set with the delete button (stored in a variable) as the Element, UpLevels at 4, and puts the Ancestor (the DIV) into another variable.

Then I loop through all the children of the Ancestor using a Get Children activity, set to FIND_CHILDREN. When I get to the child that has the word “userActions” in the Style property, I stick it in a variable. This should be the Actions button specific to the user I need to delete.

It seemed like it was working, but something odd has happened. One company has two users with similar user IDs (not sure if that’s the cause) of breeves and bobreeves. It’s supposed to delete breeves but it’s deleting bobreeves.

I have no idea why this is happening, my logic seems sound and through extensive testing and multiple runs live it appeared to be working, except it keeps getting crossed up on these two specific users.

Here’s the HTML code containing the Actions menu and submenu buttons. I know this is a complicated one but I’m stuck and am hoping someone might have a better way of getting and clicking the correct Actions button.

I’ve included the HTML for just one user’s actions buttons. The other user’s is identical except for the first name, last name, user ID, and numerical identifiers within the Style properties.

EDIT: couldn’t get it to display the HTML code so I’ll attach it in a text file

actions_menu.html (3.8 KB)

OK I figured it out.

webctrl class=“deleteUser*” + CurrentUserID + “*”

If CurrentUserID is mjones but there’s also a jimjones, since mjones is contained within jimjones it’s matching when it shouldn’t.

So I changed the selector to make it more precise:

<webctrl class=‘deleteUser username: ‘" + CurrentUserID + "’,*’ tag=‘button’

And now it works properly.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.