Lagencie's avatar
Lagencie
Frequent Contributor
6 years ago
Status:
Implemented

Name Mapping with XPath

I would love to have a new feature, where you can map objects using the xpath.

 

The problem with the current object mapping is, that it only supports a given set of tags, which gets harder and harder, with all those custom html tags and the new standards, that use more of those custom tags ... + angular 2 libraries are not supported either.

 

 

I have a couple of tags in my current project, that I can only select within scripts with the findchildbyxpath method ... like mat-select, accordion-group-container and all those can be easily selected / clicked / typed into with xpath finding but the object mapping doesnt recognize it and therefore I can not interact with it other than within scripts.

 

 

Mapping objects with their xpath would make all of this possible and also makes it easier to generate more flexible structures of name mappings like if its a generated website, you can leave some panels blank with just using the // xpath to select a lower level rather than one step down with the current panel system

7 Comments

  • Status changed:
    New Idea
    to
    Selected for Development

    Hi! This will be available in v14.50. 

     

    TestComplete will automatically recommend a set of XPaths and CSS Selectors for each object when the 'cross-platform web testing' mode is selected. These will be automatically added to the Namemapping repository during test creation. If a specific selectory does not work, TestComplete will automatically select another suitable selector that works and continue running the test. The benefit of this capability is that your tests will be less flaky and your test maintenance time will be reduced significantly.

     

    You can add your own custom selectors as well, and also remove the default selectors suggested by TestComplete. 

     

    Here is a visual representation of how Sectors will be stored in Namemapping:

     

    We plan to release this feature mid-July 2020.  

     

    The proprietary way of using Namemapping without Xpath and CSS Sectors will also be available in the default mode of object recognition. 

  • Big Problem here to solve is also that the xpaths generated from Testcomlete during Mapping of Objects are mostly useless and in fact i have to evaluate proper and more stable xpaths with browser addons like Ranorex Selocity, then remove the generated xpaths and then add the stable xpath to the mapped object.

    This is very frustrating.

    Is there an option to turn off the auto generated xpaths and instead during mapping give us the option to type in a stable xpath. This would eliminate the need to remove the auto generated xpaths afterwards

  • Thanks for your comment. Could you send us an example of the website under test, the controls where object identifiers are poor and the stable identifier you replace them with? We will improve our internal algorithm so you wouldn't need to replace identifiers. 

  • prashantmohan 

    Example Element (unmute button):

    Testcomplete has generated following xpaths:

    The last 3 xpaths are useless. Assume the unmute button is clicked. In my case the custom attribute (data-test) changes to data-test='mute-control'.
    I cant map the mute button as a new mapping object because it is getting recognized as "b_unmute" because of the last 3 xpaths.
    So first i have to delete the 3 last xpaths and then i can map the button "b_mute"

    Also for the left over css selectors i delete 1 of them and sometimes i replace them with an xpath because for me it is more readable (also question here is why the mix up between css and xpath -> is using css selectors faster?). Using Css selectors over xpath indeed is considered better practice so the question is answered.



  • @prashantmohan 

     

    To expand on this discussion, the current name mapping also causes trouble with dynamic websites like ours, where the DOM changes a lot based on user input. Take for example the selector "//ul/button", which can map to a button in any unordered list which appears.

     

    In our case, each object on the site has a unique ID, save for a few react-objects which didn't want to play along. Therefore, all name mapped objects are mapped manually, either using their IDs or mapped as a child object of the closest parent with an ID.

     

    Although improving the internal algorithm is a great first step, I imagine it would be very difficult to make it work with dynamic websites like ours, as Testcomplete can't see all elements of the site at any given time. As such, giving the user the ability to explicitly state which selectors to use or not use when automatically name mapping using CSS selectors and XPath would be greatly appreciated.