This is a migrated thread and some comments may be shown as answers.

Extract element not working

1 Answer 70 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Igor
Top achievements
Rank 1
Igor asked on 19 May 2011, 03:00 PM
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
        Manager.LaunchNewBrowser();




        // Navigate to : 'http://demos.telerik.com/silverlight/#GridView/Totals'
        ActiveBrowser.NavigateTo("http://demos.telerik.com/silverlight/#GridView/Totals");




        // Wait for '3000' msec.
        System.Threading.Thread.Sleep(3000);




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




        // Navigate to : 'http://demos.telerik.com/silverlight/#GridView/Totals'
        ActiveBrowser.NavigateTo("http://demos.telerik.com/silverlight/#GridView/Totals");




        // Wait for '3000' msec.
        System.Threading.Thread.Sleep(3000);




        // 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));




}


1 Answer, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 23 May 2011, 12:52 PM
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 >>

Tags
General Discussions
Asked by
Igor
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
Share this question
or