Forum Discussion

bewen's avatar
bewen
Occasional Contributor
2 years ago

Searching for an element within elements with no specific identifier

Hi, im trying to access a + button to click and expand a set of <li> items the structure is as follows:

<ul>

   <li class="title1">

      <span class="button"></span>

      <ul>

 

      </ul>

   </li>

   <li class="title2"></li>

   <li class="title3"></li>

   <li class="title4"></li>

   ...

</ul>

 

The layout as follows has multiple <li> items which all contain the <span> element which when clicked expands the following <ul> element shown within the first <li> item. The <li> items all have specific 'title' attributes and the <span> button always has the same class. 

 

How would I able to use TestCompletes FindElement function in order to specifcally pick the <span> element within the <li> element containing the title 'title1'

 

Apologies if this question has been asked before, I just havent been able to fix the issue yet. 

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Use Keyword test, to record your actions. Then convert the keyword test to scripts. You'll see the properties that TC has captured, which you can then use in FindElement.