Object in Name Mapping only using the first selector (Web application)
For a few days, I have multiples issues with TestComplete that is using only the first selector of the object in the Name Mapping.
I have an object that has to 2 selectors. Sometimes, the first one is visible on the screen and some other times is the second one that is visible.
When I run my keyword test and it's the second selector that I need, it fails and in the "Details" tab on the report log" you can see that TestComplete has only looked in the first selector.
If I move up the second selector at the first position it worked but now the other keyword test won't work anymore.
Can somebody help?
I've added the [not(@style="display: none;")] and it seems to resolve the issue but I'm style wondering why it returns an error. I read this in the TestComplete documentation regarding the selector:
When locating the object, TestComplete will go through the specified selectors one after another in the order the Name Mapping editor lists them until it finds an object that matches the selector or until there are no more selectors left.
Solved! Go to Solution.
TestComplete will search for an object based on the properties you supply and return the first one that matches your criteria. If you don’t define the criteria narrow enough, then it might find a very similar object but not the one you desire or expect.
In your case the application probably has both the AccountCash and AccountCreditCard listboxes created in memory. However, the AccountCash listbox, based on some condition, hasn’t been made visible and has a width of zero, top left and bottom right points both are at the same location (0,103).
By narrowing your criteria (adding not(@style="display: none;")) you are searching for visible textboxes, so the AccountCash textbox, which is not visible and has zero width, is not found and TestCopmlete then moves to your second xpath definition.
You can see in the image below if you search for a window that have a WindClass of XLMAIN, then TestComplete might find the Windows(“XLMAIN”, “”, 2) window and not Window(“XLMAIN”, “Book1 – Excel”, 1), which is the visible window.
I hope this helps.