Forum Discussion

vondie's avatar
vondie
Contributor
8 years ago
Solved

Data Driven Loop with Image Link Variables from Excel

I currently have a Data Driven Loop set up to run through a variety of different variables from an Excel file. I have a step in the loop test that requires clicking an image object to go to the next step. Right now I have one image object hard-coded in the Keyword Test but the selected image object needs to change based on the scenario for each separate row of the Excel sheet.

 

Is it possible to enter something in a column on the Excel sheet for the desired image object so TestComplete knows which image object I want to select?

 

The object names are very long: Aliases.firefox.pageMeterSele.formAppform.panelRowWrapper.panelRow.panelRowContainerFull.panelConstrain.imageMeterplus2Jpg

 

 

  • I figured out a way to accomplish my task without using the FindChild method by using a series of nested If...Then statements.

     

    The logic looks like this: 

    If... [spreadsheet lists this word]

         then... click this object.

    Else

          If... [spreadsheet lists this other word]

                 then... click this other object...

          Else

                 return

4 Replies

  • djadhav's avatar
    djadhav
    Regular Contributor

    An easier option would be to use the FindChild method to find the image name that you will provide in the excel sheet.

     

    FindChild : https://support.smartbear.com/viewarticle/69449/

     

    Algorithm:

    Declare ParentObject & ChildObject

    Assign ParentObject

    Assign ChildObject = ParentObject.FindChild("ImageName",ImgNameFromExcel,5)

    If ChildObject Exists Then Do something

     

    NOTE: The above algorithm has to be coded in your language of preference

  • I figured out a way to accomplish my task without using the FindChild method by using a series of nested If...Then statements.

     

    The logic looks like this: 

    If... [spreadsheet lists this word]

         then... click this object.

    Else

          If... [spreadsheet lists this other word]

                 then... click this other object...

          Else

                 return

    • djadhav's avatar
      djadhav
      Regular Contributor

      vondie, I am glad you were able to make it work.

       

      The few advantages of using FindChild are,

      1) You can add, edit and update the list of image names in excel without changing your script.

      2) As your list grows, this will keep it manageable.

      3) It is better design. Hard coded values in scripts is not a good idea.

       

      But if you don't have too many items, your solution would work perfectly fine as well. Good job.