Forum Discussion

aLostDawg's avatar
aLostDawg
Occasional Contributor
13 years ago

Assigning Data Driven value to Object attribute

Not sure if I'm considered a novice, as I have many years using TestPartner, QTP and other tools. Only been using TestComplete about a week now. 



TestComplete Version: 9.0.1312.7

Microsoft Windows Version: 7 Enterprise



Scenario:

I've built a data driven keyword test that uses two sheets off of the same .xlsx file. The first loop determines which server I'm going to be testing the web page against. I have all of my servers set up in this file with a 'Run' column with 'Y' denoting which servers I will be testing against. This works great and iterates through the servers. It's the next one that I'm having issues with. 



The second loop determines which Forms will be run against each server. This also is set up with a 'Run' column so that I can have all of my data there, but only run specific forms. It selects the Form from a droplist in the AUT based on an object that has the outerText value set to a variable 'FormName' that is passed in from the DataTable. The first one works great. The subsequent times that it goes to pick the Form from the droplist it selects the original value of the 'FormName' variable. I've verified via log messages that the value of 'FormName' is changing. 



In looking at the Additional Info it looks like it may be testing against the Cell coordinates, not the attributes.

Sys.Browser("iexplore").Page("Page").Panel("createForm").Frame("createFormPaneliframe").Table(0).Cell(0,
0).Table(0).Cell(7, 2)



Is there some way to reset the object so that it dumps the previous 'FormName' out of the outerText attribute value? 



I thought I might have to send the 'FormName' as a parameter to the child keyword test, but there isn't a way to connect the object to the parameter of a keyword test as far as I can tell. 



Any ideas on what I might be doing wrong? 




  • aLostDawg's avatar
    aLostDawg
    Occasional Contributor
    So I've been digging some more and here's what I've found. 



    I added the object to the watch list and right before the keyword test clicks the 'FormNameB' the object is referring to 'FormNameA' throughout it's values (content text, FullName, innerText, Name, outerHTML, outerText, and RowIndex) even though the only selected object attributes in the mapped object are ObjectType: Cell, ColumnIndex: 2, and outerText: FormNameB (Project Variable, FormTypeFromDataSheet). 



    For some reason it looks like the instance of the object has 'FormNameA' and all it's attributes stuck in memory. 



    Is there any way to dump the value of an object with a keyword test?
  • ravisangam's avatar
    ravisangam
    Occasional Contributor
    I think you are not setting the Object correctly. Are you using Aliasing/Namemapping. I think while creating the object you are hard coding it for FormNameA. 
  • aLostDawg's avatar
    aLostDawg
    Occasional Contributor
      Thanks for the feedback. I could have set it up incorrectly, but I don't think so. Here's what I did. 



      I opened the drop-list and mapped the objects of it. The drop-list isn't a typical drop-list. It's a 3 column table that is dynamically generated on the fly depending on user/privileges/server and other info. Column 3 (index 2) contains the cells that have the most unique info, so I'm mapping the object on this cell. I created a Project Variable called "FormTypeFromDataSheet" that is assigned the FormType from the Data file. 



    Object mapping info:

    Sys.browser.WebApp.panelCreateformpanelbg.frameCreateformpaneliframe.table.cell.table.cellFormType



    Object attributes:

    ObjectType: Cell

    ColumnIndex: 2

    outerText: (Project Variable, FormTypeFromDataSheet)





      Here's why I think I set it up correctly. 



    Scenario 1:

    DataFile



    Run  |  FormType

    Y     |  FormNameA

    Y     |  FormNameB

    Y     |  FormNameC

    N     |  FormNameD

    N     |  FormNameE



      When I run this the first time through the inner loop that iterates through the forms it works for FormNameA, and when it gets to FormNameB the object tells the Click action to click on FormNameA, and when it gets to FormNameC the object tells the Click action to click on FormNameA again. I have Log Messages to output the value of FormTypeFromDataSheet and it is correctly iterating from FormNameA to FormNameB and then to FormNameC. 



    Scenario 2:

    DataFile



    Run  |  FormType

    N     |  FormNameA

    Y     |  FormNameB

    Y     |  FormNameC

    Y     |  FormNameD

    N     |  FormNameE



      When I run this the first time through the inner loop that iterates through the forms it works for FormNameB, and when it gets to FormNameC the object tells the Click action to click on FormNameB, and when it gets to FormNameD the object tells the Click action to click on FormNameB again. Again the Log Messages show the value of FormTypeFromDataSheet and it is correctly iterating from FormNameB to FormNameC and then to FormNameD. 



    Scenario 3:

    DataFile



    Run  |  FormType

    N     |  FormNameA

    N     |  FormNameB

    Y     |  FormNameC

    Y     |  FormNameD

    Y     |  FormNameE





      When I run this the first time through the inner loop that iterates through the forms it works for FormNameC, and when it gets to FormNameD the object tells the Click action to click on FormNameC, and when it gets to FormNameE the object tells the Click action to click on FormNameC again. Again the Log Messages show the value of FormTypeFromDataSheet and it is correctly iterating from FormNameC to FormNameD and then to FormNameE.





      So from these results I gather that the object is set up correctly. If the FormNameA information is hard coded then I would think that Scenario 2 and 3 would be choosing FormNameA each time instead of FormNameB and FormNameC respectively. 



      This makes me think that the Object is correctly grabbing the variable information at the beginning of a test run, but it doesn't look like it's changing the object attribute (Project Variable, FormTypeFromDataSheet) between iterations of the Data-Driven Loop. 



      Any other ideas? 
  • aLostDawg's avatar
    aLostDawg
    Occasional Contributor
      Since I've received no response to this I'll share the solution that I found for future users. 



      The solution is simple, but wasn't real easy to find. Like I suspected, the mapped object wasn't releasing the first set of values it was given in iteration 1 of the Data-Driven loop. Because of this it was selecting the wrong object in iteration 2, 3, and so on. I suspected that I needed to dump the objects attributes so that the object would get the current value of the variable and the new attributes based on the variablized attribute. 



      To do this in a KeywordTest you take and insert a Call Object Method line before the line that uses that object. Set the object in the Call to the object that is changing (based on the variable) and use the operation RefreshMappingInfo. This re-gathers the objects other attributes based on the mapped attributes. 



      I hope this helps someone else having this issue.