Forum Discussion

sothqamb's avatar
sothqamb
Occasional Contributor
3 years ago
Solved

Mapped objects being mapped again with some of the exact same selectors

I am trying to map a calendar date picker and after I map one of the dates it maps with 4 selectors as shown below If I remove the first selector (//td[.='31']) and try to inspect the same dat...
  • AlexKaras's avatar
    3 years ago

    Hi,

     

    Everything is quite simple 🙂

    Priority of selectors (and this is documented) is defined by their order. So TestComplete first searches for the object using first (topmost) selector. If the search fails, then second selector is given a try. (Note OR operator) And so on until the search succeeds or the end of the list is reached.

     

    From your description, it looks like that date selector in your application is implemented as an html table where each table's cell defines a date. And the cell in the table is implemented via the <td> tag.

    So, when you mapped the date, TestComplete mapped it as a <td> element (which is top-level element in the hierarchy) that has value equal to 31. Definitely, this is 'hard-coded' mapping, but I bet that table cells in the date picker do not have other stable and unique attributes but the value of the cell.

     

    For html tables, TestComplete provides additional .cell property that makes it possible for test code to reference some table's cell using <row,column> notation. That is why you can address cells with dates from your test code if you work not with the cells themselves but with their parent table object.

     

    P.S. Personally I found automation of date picker controls to be complex and not worth efforts. So, unless you need to test date picker itself, a bit alternative approach usually works fine for me:

    -- Focus date field and type required date into it (or assign a date to the field's value if the field is not editable);

    -- This usually causes date picker control to be displayed and focused with the entered date been selected;

    -- Send .Keys("[Enter]") to the control to confirm date selection and to close date picker;

    -- Continue with the test.