Forum Discussion

prabhjot88singh's avatar
prabhjot88singh
Contributor
5 years ago
Solved

How to Compare Unread Messages on top of web page with Center Panel

Hello Team,

I have a Securing Messaging Inbox Page

Under this page,

1. Top right of web page, where it says New Messages, a number is displayed as 4 unread messages.Highlighted in the screenshot

2. Middle section of Page has those 4 unread messages with icon as red present next to them before From section, Highlighted in the screenshot.

I need code to compare whatever number of unread messages are displayed on top of Page under Point 1 New Messages section, are equal to number of unread messages in the middle section , before From column.

Please share the code.

Attached is the screenshot

  • Note:

     

    We cannot give you code because code in TestComplete requires object identification parameters (NameMapping) of the objects in question.  I can give you how I would do it.

    1) The object in the upper right with the number of unread messages.  I would capture the value of whatever property on that object contains that number and store it in a variable within the test.

    2) I would create a for-loop on the table of messages itself from top to bottom, indexed against the number of rows on the table.

    3) Initialied before the forloop would be another variable that will be used to store the count of records with the red envelope

    4) Inside the loop, for each iteration of the loop, I'd look at the properties or values in that column containing the envelope.  Perhaps there's osmething in the innerHTML or an image name or something that indicates what type of indicator is there.  For each red envolope found, increment the counter from #3 by one.

    5) Once the for-loop is complete, compare the two variable values.  If they are equal, do nothing -> Test passed.  If they are un-equal, log a message (error or warning) indicate that they are not equal and include the values for each variable.

3 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    What code did you try and what happened when you tried it?

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      Note:

       

      We cannot give you code because code in TestComplete requires object identification parameters (NameMapping) of the objects in question.  I can give you how I would do it.

      1) The object in the upper right with the number of unread messages.  I would capture the value of whatever property on that object contains that number and store it in a variable within the test.

      2) I would create a for-loop on the table of messages itself from top to bottom, indexed against the number of rows on the table.

      3) Initialied before the forloop would be another variable that will be used to store the count of records with the red envelope

      4) Inside the loop, for each iteration of the loop, I'd look at the properties or values in that column containing the envelope.  Perhaps there's osmething in the innerHTML or an image name or something that indicates what type of indicator is there.  For each red envolope found, increment the counter from #3 by one.

      5) Once the for-loop is complete, compare the two variable values.  If they are equal, do nothing -> Test passed.  If they are un-equal, log a message (error or warning) indicate that they are not equal and include the values for each variable.

      • RUDOLF_BOTHMA's avatar
        RUDOLF_BOTHMA
        Community Hero

        Variation on tristaanogre :

         

        Step 1 remains unchanged.

        2. Find something unique to the red envelope image e.g.

        //Assumes you have the grid name mapped
        
        var Properties = ["ObjectType","namePropStr"];
        var Values = ["Image","redenvelope.png"];
        
        var envelopes = mygrid.FindAllChildren(Properties, Values).toArray();
        var linesWithEnvelopes = envelopes.length; //This is the actual count

         move on to step 5 to compare expected value with actual