Forum Discussion

romanmfs's avatar
romanmfs
Frequent Contributor
7 years ago

Different fields with same object name

Hi all!

 

Need help with this problem.

 

I have a box with bunch of fields containing a customer information (web app) that turned out to have same object names.

Is there a way to differentiate these fields even though they are named the same way (same object).

 

I am trying to set up different checkpoints on the text the fields contain but since they all named the same way my checkpoints do not work.

 

See screenshots, thanks.

  • lol. What is the DOM like?

     

    For example in Chrome, you can right click an element and click on 'inspect' and that can take you to the DOM.

     

    Maybe its like 

    <li>
      <label>First Name</label>
      <input name='field' > </input>
    </li>
    <li>
      <label>Last Name</label>
      <input name='field' > </input>
    </li>
    <li>
      <label>Email</label>
      <input name='field' > </input>
    </li>

    You see, each input has the same name, but their label may be different. In this case, you find the label first, go up to the parent then drill back down to the child.

     

    var EmailLabel = dom.Find("Label","Email")

    var EmailField = EmailLabel.Parent.Find("input", "field")

     

    Something like that.I don't use TC for web testing so this is high level pseudo code. But it should follow this pattern I think.

     

    • romanmfs's avatar
      romanmfs
      Frequent Contributor

      I am doing simple keyword editing and thats the example of the field when I click inspect.

      It doesnt have a label tag, even if I find it I am not sure how am i suppose to implement it/ rename object??

       

      <input type="text" size="20" autocomplete="off" id="ext-comp-2500" name="email_address" class=" x-form-text x-form-field " style="width: 173px;">

  • SanderK's avatar
    SanderK
    Occasional Contributor

    It seems like Id and Name can be used to distinguish individual textboxes. I would map them based on their ObjectType and Id.

    • romanmfs's avatar
      romanmfs
      Frequent Contributor

      Am I understanding this right?

       

      What I tried is to toggle Id and Name and enter the values there to check?

       

      I am checking for text in the field. 

       

      I am only able to check one property to check, I get an error message when I try to check 2 or more properties (only allowed 1 property).

       

      I really need to get this to work, please help:)

  • SanderK's avatar
    SanderK
    Occasional Contributor

    No, what I meant was to map the text fields based on their ObjectType and Id or Name properties. See the documentation linked below if you don't know how to use the Name Mapping. Once a field is mapped (it saves you the trouble of having the test search for it everytime you need it) you can just call the Text-property of it in your test and check if it is correct.

     

    https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/index.html

  • romanmfs's avatar
    romanmfs
    Frequent Contributor

    Thanks A lot SunderK!!!

    I was able to figure it out just like you advised.

    I created new objects for needed fields and mapped them according to their labels.

     

  • What i meant is look around the parent, siblings.

     

    Are any of the parents or siblings named? Can you find it contextually? 

     

    Edit : Judging by a screenshot, there's obviously a label on the form. How could there be no labels?

  • SanderK's avatar
    SanderK
    Occasional Contributor

    Do the fields have an Index property? In that case you can map them based on their type and index on the page as long as they always appear in the same order.

    • romanmfs's avatar
      romanmfs
      Frequent Contributor

      How do I check if it has index property?...

  • SanderK's avatar
    SanderK
    Occasional Contributor

    Open the checkpoint wizard, choose Object property and drop the crosshair on one of the fields. Then click Next and Advanced and you'll get a list of all the field's properties and their values.

  • romanmfs's avatar
    romanmfs
    Frequent Contributor

    Here is what I got. (see images).

     

    Aslo i am only able to pick one property being checked.