Forum Discussion

yassine's avatar
yassine
Occasional Contributor
9 years ago

Testing .NET desktop application based on Magic xpa

Hello everyone, 

 

I am a starter in automation test with TestComplete, I could automate the first test case for my web application without problem, but when I start testing our desktop application I had some problems with recognation object in object mapping.

 

The application SUT is a .NET desktop application based on Magic xpa Application Platform

 

As you can see in attached image I have a control table with a list of rows that present my commands, what i am trying to do is to verify the total value for my first row, the problem is that TestComplete can only detect the full table as a single element and cannot access to table cells, can some one help me to resolve this issue.

 

 

23 Replies

  • AlexKaras's avatar
    AlexKaras
    Icon for Champion Level 1 rankChampion Level 1

    Hi,

     

    And, in addition to the said others above:

    Your Object Spy is in Basic view mode (see grey panel on your Issue2 screenshot). Switch it to Advanced one by clicking the link on the right (and do the same for Object Browser if not done already). Hopefully, this will provide you with more accessible methods/properties...

    • Colin_McCrae's avatar
      Colin_McCrae
      Community Hero

      Jeez! I'm half asleep today! Didn't notice it was in Basic view either ....

      • baxatob's avatar
        baxatob
        Community Hero

        OK guys.

         

        What do you think, if we add yassine table's class to Microsoft Controls -> WinForms -> DataGrid

         

        Then we can try to run the following script:

         

        function Main ()
        {
          var Grid, Col;
        
          Grid = Aliases.yassineTableControlAlias;
        
          for (Col = 0; Col < Grid.wColumnCount; Col++)
            Log.Message ("Cell (0, " + Col + ") value: " +
                         Grid.wValue(0, Col).ToString().OleValue)
        }

        In the case of success we should receive values for the first row.

    • Colin_McCrae's avatar
      Colin_McCrae
      Community Hero

      I don't think the generic "how to use grids" support page is going to help here.

       

      I have never heard of Magic xpa, but looking at the classname of the grid in the snapshot, it looks like a control specific to them. If they are supported as a 3rd party control type by TestComplete, I can't find any reference to it. The only thing I can find is an unresolved forum thread from 2 years ago ....

       

      https://community.smartbear.com/t5/TestComplete-Functional-Web/Anyone-using-TC-with-Magic-XPA-web-interface/td-p/92425

       

      Given that grids can be complex when supported fully by TC, I can see trying to work with an unsupported type as not a lot of fun.

       

      If it's based on a supported class (is there a way of finding that out?) you should be able to link it. But I have no idea if that will expose the methods and properties you're after.

       

      Good luck!

  • yassine's avatar
    yassine
    Occasional Contributor

    Hello Guys, 

     

    Thanks for all your replies, they were very helpful, I tried to add the classname to object Mapping setings : Microsoft controls -> WinForms -> DatagridView and that gaves me more properties, adding to that I used advanced view, the result was that I am able to detect columns number, I think according to what was said, I can't map the needed cell using "Object Spy", but it can the cell value can be accessible by developing some scripts, will try to  access the value needed by scripting

     

    still one problem i don't know how to solve it according to this new properties, the second verification, i have to verify for every item in the table the quantity and the final price with data in an Excel file, and according to the properties, there is an exception in the wRowCount, how can i loop my table and extract cell values without having rowCount value that will help in loop setting

    • Colin_McCrae's avatar
      Colin_McCrae
      Community Hero

      This is where grids can get a little funky. Especially if you're not 100% sure of the base class.

       

      I have grids that show this error for the column count. But the row count property is fine. In my case, columns are referred to as "fields" and there are other properties where I can get this info. Have you have a good dig around in the other properties and fields available? It may well be hidden away somewhere under another name.

  • yassine's avatar
    yassine
    Occasional Contributor

    Thanks Colin_McCrae,

     

    Actually there are some other properties that gives the row number like you can see in the picture, so I think that this can help me to get the values I need from the cells of my table. Excuse me because I am beginner in scripting, using the code given by baxatob It gives me a problem because of the wRowCount that is not defined, can you please show me other ways to extact the values from the table.

    • Colin_McCrae's avatar
      Colin_McCrae
      Community Hero

      So 121 is your row count then yes? You're happy that's the correct number?

       

      I don't know how you address cells in this grid type as I've never used it. Your earlier screen shot showed a "wValue" property, which requires parameter(s) to expose it's value or underlying components. It might be that? (Say - "wValue(1,1)" might return the contents of the cell at position 1,1 - as baxatob posted in his code snippet) I don't know. As I say, different grid types present their data in different ways.

       

      I don't see anything else in your screenshots that looks like it may relate to the current cell. From what I can see on the screenshots, "wValue" and "wColumn" both take parameters, and can be drilled down further. Could be those. Could be another property .... impossible to say without seeing them.

      • baxatob's avatar
        baxatob
        Community Hero

        So the problem is that we can't obtain a wRowCount property.

         

        Not sure about Magic xpa application, but there is a limitation for Borland grids: The property can also be unavailable to your scripts if it is not used in the application code. Link , see "Remarks" >>

         

        Possibly that is a peculiarity of compilation and it can be solved together with developers. 

         

        As a workaround you can hard-code a row count.

  • yassine's avatar
    yassine
    Occasional Contributor

    Thanks Colin_McCrae and baxatob for your replies and your interests,

     

    The solution I am trying to test is not developped by our company, so like you I have no idea what classname they use or what Magics xpa is based on, accoding to what I've seen in object properties I guess it is a custom grid because every time I scroll down to the end list the grid looks for more older data and fill the grid so it an infinite scrolling and I think that make magics xpa grid a custom component.

     

    the properties that I get gives me the columns count and the rows count(using the property virtualItemCount), but what I think is that methods like wValue or ClickCell used some Row count in their implemtation so without having the property wRowCount those methods cannot work.

     

    I think as a solution I can hard code row count value suing vertualItemCount's value, To do this i wrote ;

     Grid.wRowCount = Grid.VirtualItemsCount;

     and i think that i do it wrangly because it gives me error, baxatob please can you help me to do it right

    • baxatob's avatar
      baxatob
      Community Hero

      No-no-no! 

       

      Just use VirtualItemsCount property instead of wRowCount

      • Colin_McCrae's avatar
        Colin_McCrae
        Community Hero

        That will check a single row (using the single loop in your original snippet).

         

        It you want all cells, you'll need a nested loop.

         

        (Pseudocode)

         

        Loop Rows (Using item count)

        Loop Columns (Using column count)

        Get Cell/Item Value(Row, Column)

        End Columns Loop

        End Rows Loop