Change in way Datagrid cell text is read in 2012R1 vs 2011R1

7 posts, 0 answers
  1. Shashi
    Shashi avatar
    25 posts
    Member since:
    Feb 2011

    Posted 26 Apr 2012 Link to this post

    Telerik team,

    We are currently on version 2011.1.825.0.  I am running all our existing tests against the latest version (2012.1.411.0) in preparation for upgrading to that version.  A few of our tests are failing in 2012 R1 - which aren't failing in the version that we are currently on. 

    One of the failures appears to be due to a change in the way Datagrid cell text is read by Test Studio between the two versions. 

    The Datagrid cell in question contains text in the format "abcde - fghi".    
    DatagridCell contains 3 text blocks:  one for 'abcde', second for the hyphen and the third for 'fghi'. 
    DOM structure is identical between the two versions (see attached images of the Datagrid DOM in both versions) - not surprising as I am running against the same version of the application in both cases.

    The test step is trying to verify that the contents of the cell matches a value in the same format as follows:

    Verify: DataGridCell text 'Equal' 'S4960 - 114'. <Claim #> - DataDriven: 
    [$(AllocatedClaimNumber)]<BR>

    The step passes in the currently installed version (2011.1.825.0) but fails in 2012.1.411.0.

    When I go into record mode and try to re-record the verification step in both versions, I found that 2012R1 only compares against the first text block (i.e. abcde) - whereas 2011R1 compares against the combined contents of all 3 text blocks i.e. "abcde - fghi" (the latter is obviously what we want).  Please see the screen shots of the commands list for the datagrid cell in the two versions.

    Question:  Is this change in behavior a bug or by design?  If it is by design, how would you recommend we fix our code to make it work under the new version?  (It seems to me that I will need to go to code-behind to do this).  

    We are using Test Studio plugin for Visual Studio in a Microsoft Test Manager/TFS environment - and our AUT is a Silverlight 4.0 application.

    I know we are several versions of TS behind - so it is possible that this change may have occurred in one of the later 2011 versions and not 2012.  Nevertheless, it is currently an issue for us - and so we would appreciate your input so we can decide next course of action.

    I look forward to your prompt response.

    Thanks,
    Shashi

  2. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 01 May 2012 Link to this post

    Hello Shashi,

    It seems you've stumbled onto an oversight after an underlying code change was made:

    • In the old version, DataGridCell.Text returns all child TextBlocks combined (S4960 - 114).
    • In the new version, DataGridCell.Text returns just the first child TextBlock (S4960).
    • In the new version, DataGridCell.TextBlockContent returns all child TextBlocks combined (S4960 - 114). 

    So it seems crafting a verification through the UI is still using .Text, thus behaving the way you described. I filed a bug report for this and you can track the PITS Issue here: Public URL. I also updated your Telerik points accordingly for reporting this.

    In the meantime, as you suspected, use a coded step and reference DataGridCell.TextBlockContent to get the desired value.


    Regards,
    Anthony
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Shashi
    Shashi avatar
    25 posts
    Member since:
    Feb 2011

    Posted 21 Jun 2013 Link to this post

    Anthony/Telerik,

    I am running our tests against the latest official version (2012.2.1420.0) and see that the issue below is fixed.  However, it has caused some of our existing tests to fail in the new version (they are passing in our current version 2012.1.411.0).  The problem is as follows:

    The recorded version of Datagrid cell text is now returning a concatenated string of all 3 text boxes (which is as requested below) - however, it does this even if the other two parts are not visible.  In our case, we have instances where 2 or all 3 child text boxes are populated but only the first is visible in the application.  The new behavior of the recorded Datagrid cell text is causing tests to fail in these scenarios.

    Is this behavior by design?  If so, is there any other way to get just the visible text in the grid cell - using a recorded step? (any properties I can change to get this result?). 

    I know I can accomplish this using coded steps - but prefer to use recorded steps if possible.

    Thanks and I look forward to your response.

    Shashi
    p.s. Please let me know if you prefer I start a new thread for this issue.
  4. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 26 Jun 2013 Link to this post

    Hi Shashi,

    No there is no way to get only the visible text of a DataGridCell element in a non-coded step. I have created a feature request for this here.

    I can think of two options, both require modifying your tests to be compatible with the current behavior:

    1. Update the tests to use "Contains" or "StartsWith"/"EndsWith" instead of "Exact" matching. You can add multiple verification's to get more accuracy, a StartsWith followed by an EndsWith.
    2. The following is the code needed to calculate what is visible which would allow you to add a verification on only the visible portion.
    IList<TextBlock> parts = Pages.SilverlightSampleApp.SilverlightApp.P1122Datagridcell.Find.AllByType<TextBlock>();
    StringBuilder visibleText = new StringBuilder();
    foreach(TextBlock part in parts)
    {
        if (part.IsVisible)
        {
            visibleText.Append(part.Text);
        }
    }
    Log.WriteLine("Visible Text: " + visibleText.ToString());

    Regards,
    Cody
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  5. Shashi
    Shashi avatar
    25 posts
    Member since:
    Feb 2011

    Posted 10 Jul 2013 Link to this post

    Hi Cody,

    There is actually a much simpler coded solution available (if you want to go that route).  The Text property of the datagridCell object returns the visible portion of the text (in contrast, CellText now returns all text) - so you can simply do the following:

    visibleText = Pages.SilverlightSampleApp.P1122Datagridcell.Text;

    Currently, if you record a new Verification step for a datagrid cell text, the value used for comparison is the entire text (visible and invisible) - see example below.  I don't know what you are hearing from other users - but I imagine that could be a little puzzling and unexpected to some especially if they are not familiar with the DOM. For this reason, I think the recorded version of Datagridcell text should return only the visible text by default - you could have an option on the command or a separate gettext command to return all text. 

    Verify: DataGridCell text 'Equal' 'Patient  (In-Active)'.  // in this case, "(In-active)" is not visible on the UI

    Finally, I also discovered that Verify steps on datagrid cell values (such as the one above) yield an empty method when you take it to a coded step.  Could you confirm?

    I look forward to your feedback.

    Thanks,
    Shashi

  6. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 15 Jul 2013 Link to this post

    Hi Shashi,

    I have confirmed the code generation bug and filed a bug report on it here. Thank you for the report. I've granted you 500 Telerik Points for discovering this problem.

    Regarding this code:
    visibleText = Pages.SilverlightSampleApp.P1122Datagridcell.Text

    What I find is that .Text returns the text content of only the first TextBlock contained within the DataGridCell. It doesn't matter if which are/are not visible. I'm not sure what is the actual "correct" behavior. I've asked a couple people here what should the expected behavior be in this scenario. I'll update you when we reach an agreement.

    Regards,
    Cody
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  7. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 17 Jul 2013 Link to this post

    Hello Shashi,

    I have been confirmed that .Text is supposed to return the content of the first TextBlock and .TextBlockContent is supposed to return the concatenation of all TextBlock's contained with that UI element, regardless of what type of UI element it is and without regard for the Visibility setting of any of the TextBlock's. So the current version of Test Studio is behaving the way it was intended to behave.

    Also we don't see any advantage to adding some sort of switch that selects the behavior of .Text. While it's true it would make your old tests work in the current version of Test Studio, no other customer is requesting this and there's no real technical advantage to adding such a switch.

    Regards,
    Cody
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top
  Cast Your Vote at DevPro Connections! Cast Your Vote at  Win IT Pro Connections!