Ask a Question

Clicking an a tag in the same div as a span containing desired text.

MHealton
New Contributor

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:

MHealton_0-1655827770899.png

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! 

0 REPLIES 0
cancel
Showing results for 
Search instead for 
Did you mean: