llrr's avatar
llrr
Frequent Visitor
2 years ago
Status:
New Idea

Possible bug with using regexp for manual object name mapping

I have some desktop application under test where MDI windows have highly variable WndCaption property. This produces an awful lot of name mappings when I record keyword tests. Auto-generated mappings use two parameter-value pairs: "WndClass: Afx:00400000:b*" and "WndCaption: <whatever_caption>".

 

However the captions have some distinctive patterns and naturally I wanted to utilize those patterns to reduce number of mappings. So I created the manual object mappings like this:


wndType1
:

  • WndClass == "Afx:00400000:b*"
  • WndCaption == "regexp:^Object: .*"

wndType2:

  • WndClass == "Afx:00400000:b*"
  • WndCaption == "regexp:^!(Object:).* - \(.*\)$"

...


and so on, paying special attention to possible ambiguities when constructing the regular expressions. Mapping worked as expected, showing correct MappedName in the Object Browser.

Upon converting the existing keyword tests to use the new mapping, everything functioned seamlessly. However, when I attempted to record new keyword tests, TestComplete consistently generated its own mappings instead of utilizing the existing ones, despite my efforts. After some trial and error, I resorted to replacing the regular expressions with the combination of conditions and wildcards:

 

wndType1:

  • WndClass == "Afx:00400000:b*"
  • WndCaption == "Object: *"

wndType2:

  • WndClass == "Afx:00400000:b*"
  • WndCaption == "* - (*)" AND WndCaption != "Object: *"

And all of a sudden everything works like a charm! 

 

I believe this behavior is not intended, especially since I couldn't find any mention of limitations related to the use of regular expressions in the documentation available.

No CommentsBe the first to comment