Extract element not working

2 posts, 0 answers
  1. Igor
    Igor avatar
    3 posts
    Member since:
    May 2011

    Posted 19 May 2011 Link to this post

    I am having a hard time using the extract feature. I was testing it on the silverlight demo on telerk's site at the following url: http://demos.telerik.com/silverlight/#GridView/Totals

    I am trying to extract the sum value in the bottom summary column and then verify that value against the new sum when I refresh the page. However, the name of the textfield is different each time I visit the page so the extraction fails. Is there anyway to get this to work everytime?

    This is the code for my test.

    public void a6_Add_Item()
            // Launch an instance of the browser

            // Navigate to : 'http://demos.telerik.com/silverlight/#GridView/Totals'

            // Wait for '3000' msec.

            // Extract 'x532995Textblock' text into DataBindVariable $(sum)

            // Navigate to : 'http://demos.telerik.com/silverlight/#GridView/Totals'

            // Wait for '3000' msec.

            // Verify 'x532995Textblock' text Same '$5,329.95'
            Assert.IsFalse((ArtOfTest.Common.CompareUtils.StringCompare(Pages.TelerikGridViewFor.SilverlightApp.x532995Textblock.Text, ((string)(System.Convert.ChangeType(TestContext.DataRow["sum"], typeof(string)))), ArtOfTest.Common.StringCompareType.Same) == false), string.Format("Verify \'x532995Textblock\' text Same \'$5,329.95\' failed.  Actual value \'{0}\'", Pages.TelerikGridViewFor.SilverlightApp.x532995Textblock.Text));


  2. Konstantin Petkov
    Konstantin Petkov avatar
    1911 posts

    Posted 23 May 2011 Link to this post

    Hi Igor,

    Thank you for contacting us.

    Indeed, on recording we identify the TextBlock by its content so the element find expression relies on the content. To resolve this issue you can instead get the parent footer cell which is static for the GridView and use our coded find element API in Silverlight to get the TextBlock in interest and then obtain its value. To find what to look for and decide on the exact element search approach, I suggest you load the element in the Visual Tree Explorer during recording so that you can get the exact visual tree to look at.

    I've attached a capture of the visual tree of the GridViewFooterCell expanded to the TextBlock you are after. If I'm correct in my assumption the following code snippet should get to that TextBlock:

    TextBlock textBlock = cell.Find.ByType("AggregateResultsList").Find.AllByType<TextBlock>()[1];

    You can read more about the finding elements API in Silverlight in our documentation article here. Should you have further questions please do not hesitate to contact us again.

    Best wishes,
    Konstantin Petkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Back to Top