Forum Discussion

nish_b's avatar
nish_b
Contributor
6 years ago

Defining web object using Tree Model

Hi,

 

If name mapping is already present for a web object, can we still define the same web object using Tree Model? When I tried this, the object is not getting identified.

 

The way I defined the web object was by using Object Spy. I identified the web element and then copied the Full Name and assigned this to a variable and passing the variable in the script to perform actions.

Note: This web element is already having the Name Mapping. 

 

Example code snippet (JS):

var obj  = Sys.Browser("edge").Page(url).Form(formName).Panel(2).Panel(0).Panel(3).Panel(0).Textbox(txtBoxID);

obj.SetText(text); //Object wasn't getting identified.

 

When I replaced the contents on obj with the Mapped Name, it worked perfectly fine. 

 

  • You can access objects both ways... either using the Sys.Browser way or Aliases.Browser...  Why you wouldn't want to use NameMapping if you have it mapped, not sure I understand your ultimate goal here.

     

    My guess is that you probably have something wrong in the values you're using for url or formName or txtBoxID.  Keep in mind that NameMapping has all those values already in place.  NameMapping also has built object identification waiting going on.  So, I'm expecting that you might also be dealing with a timing issue where the object is not present at he time you're attempting to use it.

  • There should be no problem with using a NameMapping from one machine to another.  The mapping is based upon objects within the application under test, their properties, and their hierarchy within that application.  There should be VERY few factors in mapping that will cause a NameMapping that works on one machine to fail on another.  

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    You can access objects both ways... either using the Sys.Browser way or Aliases.Browser...  Why you wouldn't want to use NameMapping if you have it mapped, not sure I understand your ultimate goal here.

     

    My guess is that you probably have something wrong in the values you're using for url or formName or txtBoxID.  Keep in mind that NameMapping has all those values already in place.  NameMapping also has built object identification waiting going on.  So, I'm expecting that you might also be dealing with a timing issue where the object is not present at he time you're attempting to use it.

    • nish_b's avatar
      nish_b
      Contributor

      Hi Martin,

       

      Thanks for your response. Well, I was just wondering if I check-in my code in a SCM system like GIT and when others pull this code, will they have the same Name Mapping as mine? If I use Aliases.Browse to define all my objects based on the Name Mapping in my system, will it still identify correctly in other systems too? If yes, then I will go ahead with defining objects using Name Mapping itself.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        There should be no problem with using a NameMapping from one machine to another.  The mapping is based upon objects within the application under test, their properties, and their hierarchy within that application.  There should be VERY few factors in mapping that will cause a NameMapping that works on one machine to fail on another.