Forum Discussion

markbain's avatar
markbain
Occasional Contributor
15 years ago

InnerText not enough to distinguish between 2 links

I have 2 links that are basically the same link, but have different Text: EG: 'Home' and 'Welcome'.  Both links go to the home/welcome page.



When I try to change the Mapping identifying properties, I get an dialog box (see attached) that says the listed properties are not enough to uniquely distinguish them apart. 



namePropStr, href are used and their values are the same for both links,

innerText is different (as above).  But with one link already set with these properties, and then I edit the other and try to remove the 'ObjectIdentifier' property and replace it with 'innerText' and save, the non-unique dialog appears.



My question is then, what properties are used to determine 'uniqueness'?
  • Hello Mark,




    When you change the set of mapping properties for a Name Mapping object, TestComplete checks how many objects in the tested application at the same level satisfy the new set. If there are two or more objects, the dialog you get appears. Please make sure that there are no other objects (even of other types) at the same level as the link with the same set of properties. If you cannot find such objects, please post here the list of the problematic set's properties along with their exact values.

  • markbain's avatar
    markbain
    Occasional Contributor
    If I understand you correctly, I can not have 2 mapped objects at the same level with the same list of properties defined as the criteria to validate against.



    EG:



    Link1 -> (properties) InnerText: "hello", Href: "http://..."

    Link2 -> (properties) InnerText: "Not now", Href: "http://..."



    I have to have an additional 'property' associated with one of the links to not have that dialog to show up?



    Link1 -> (properties) InnerText: "hello", Href: "http://..."

    Link2 -> (properties) InnerText: "Not now", Href: "http://...", Name: "myLink2"



    It sounds like each named/mapped object is determined to be 'unique' if the list of 'properies' associated with it (at each level) is unique, and not the values of those properties.



    Is that correct?

  • Hi Mark,




    Objects can have the same set of properties, but they must have different values for these properties in order to be differentiated by TestComplete. I would like to know the exact sets of properties and values of these properties so I can try to reproduce and investigate the behavior here.

  • markbain's avatar
    markbain
    Occasional Contributor
    See images below.



    Search.jpg and linkAdvSearch.jpg are the same except for the 'ObjectIdentifier' property.

    When I 'edit-linkAdvSearch.jpg' from the Name Mapping section (above the Aliases), and remove the 'ObjectIdentifier' property, I get the 'error.jpg' message when clicking on the 'OK' button.



    Hopefully this helps.

    ----------------------



    FYI, I originally had this issue with my 'Home/Welcome' links (same situation), but I can change them without the error message.  They both have only the 'namePropStr' and 'innerText' properties, with the 'innerText' values being "Home" and "Welcome" respectfully.
  • Hi Mark,




    Thanks for sending the images. However, I failed to reproduce the problem using your steps with a simple page. I am guessing that there are more links pointing to the same URL on the tested page, and these other links cause the error you get. Could you please post here or send us via the Contact Support form (http://www.automatedqa.com/support/message/) the HTML code of the tested page? You can get the HTML code by executing the code below:




    [JScript]

    var page = Aliases.IE.NEIC;

    var htmlCode = page.Application.Document.documentElement.outerHTML;

    Log.Message("See Remarks", htmlCode);

  • markbain's avatar
    markbain
    Occasional Contributor
    Thanks David,



    I submitted a support ticket with the subject title 'InnerText not enough to distinguish between 2 links'

  • Hi Mark,




    Thanks for the HTML code. I was right - you have two identical links within your navigation list:




    <LI><A href="../Search/AdvancedSearch.aspx">Advanced Search</A> </LI>




    I think that you need just to ignore the warning message you get. Since the links are identical, there is no difference which of them will be referenced by the mapping name.

  • markbain's avatar
    markbain
    Occasional Contributor
    Thanks again for the information.



    However, I'm still confused. 

    I did find where you are talking about I have 2 links the same.  One is in the 'header' section of the page, and one is in the body of the page.



    You said earlier that if the objects are at the 'same level' (I assume this is refering to the level in the object tree) that this issue arises.  However, if you look at my tree structure (See attached image), the links in question are not. 



    The 'linkAdvancedSearch' (in green) in the page body ('Nav' in blue) is at the same level as the 'Search' link, but has different 'innerText'. 

    The 'linkAdvancedSearch' (in green) in the header ('pHeader' in blue), while has the same 'innerText', it is at a 'different level' than the one in the page body.



    Could you point out what I am missing or not understanding correctly?  Thanks.
  • Hi Mark,




    I think that the second problematic link is not present in this tree. To make sure, please try executing this code that will post names of all links pointing to the AdvancedSearch.aspx page to the log. Please make sure that the problematic web page is opened in Internet Explorer before running the code.




    [JScript]

    function test()

    {

      var page = Sys.Process("iexplore").Page("*");

      var links = page.FindAllChildren("href", "*AdvancedSearch.aspx", 100).toArray();

      for (var i = 0; i < links.length; i++) {

        Log.Message(i + "#: " + links.Name, "innerText = " + links.innerText + "\r\nFullName = " + links.FullName + "\r\nMappedName = " + links.MappedName);

      }  

    }




    When I run this script against the page you sent me, I get the following result:

    0#: Link(9)

    innerText = Advanced Search

    FullName = Sys.Process("iexplore").Page("file:///D:/test.html").Form("aspnetForm").Panel("navigation").Link(9)




    1#: Link(8)

    innerText = Search

    FullName = Sys.Process("iexplore").Page("file:///D:/test.html").Form("aspnetForm").Panel("navigation").Link(8)




    2#: Link(2)

    innerText = Advanced Search

    FullName = Sys.Process("iexplore").Page("file:///D:/test.html").Form("aspnetForm").Panel("navigation").Link(2)




    3#: Link("ctl00_HyperLink2")

    innerText = Advanced Search

    FullName = Sys.Process("iexplore").Page("file:///D:/test.html").Form("aspnetForm").Panel("heading").Panel("search_and_skipto").Panel("search_container").Link("ctl00_HyperLink2")




    The conflicting objects are 0# and 2#.