Clicking an a tag in the same div as a span containing desired text.
Hey all,
Our org is fairly new to testcomplete, and I have a feeling someone's already nailed down an elegant solution to this type of problem.
I'm working on building out some regression tests for a form page using Python scripts, and we have several multi-select input elements on this page. Select an item from a dropdown, and it will appear in a list below, along with a link to delete said item:
The quick and dirty version of the html for the list of items is:
<div id="container-for-item-list">
<div id="container-for-first-item-in-list">
<a href="javascript.removeItem(1);">X</a>
<span> Item 1</span>
</div>
<div id="container-for-second-item-in-list">
<a href="javascript.removeItem(7);">X</a>
<span> Item 7</span>
</div>
</div>
What I am hoping to do is create a function that will locate the span containing the text "Item 1", and then click on the <a> tag within the same div, deleting that item. At this point, I'm able to find the span containing the text I want, but am uncertain how to then access and click on the adjacent <a> tag. Any help you have to offer would be greatly appreciated!
Try using FindAll Method to search for "Link". For example,
function MenuItems() { var menuitems = Aliases.panelMainMenu.FindAll("ObjectType", "Link", 1); for (var i = 0; i < menuitems.length; i++) { Log.Message(menuitems[i].Name); } }
This will output the Link name.
You can then perform menuitems[i].Click() if the menuitem equals what you want.