Forum Discussion

TestCoeUs1337's avatar
TestCoeUs1337
Occasional Contributor
2 months ago

Selecting n-th element using CSS selector

Hello everyone,

I'm currently working on automating a date-picker element in TestComplete, and I'm trying to achieve a functionality similar to what I've done in other frameworks using CSS selectors. In my case, I locate 30 buttons that represent days in a month.

My question is, can I store the CSS selector of these buttons in a variable and then click on a specific day, for example, the 5th, by passing the index to it and using the .Click() method?

(I've done it previously with cypress using .eq(index) to click on the given element?

Any insights or examples on how to accomplish this in TestComplete would be greatly appreciated. Thanks in advance!

3 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Depending on the control, it could be possible. For example, the following date picker control is identified as a table - cells can be stored into an array that represents the dates. Also the date picker may have methods you can call to set a specific date too.

    Use the Object Browser to see what the control exposes.

    • TestCoeUs1337's avatar
      TestCoeUs1337
      Occasional Contributor

      Thanks for your reply.. but if it was not for the date picker? For example if I had 5 buttons on the page and want to select third one? Can you do an equivallent of cypress .eq(2)? (starting indexing at 0...)? 


      • rraghvani's avatar
        rraghvani
        Champion Level 3

        I'm not familiar with Cypress, but same principles apply. In this example, buttons can be accessed via their index value.