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

How to Write Code for textblock to click

3 Answers 55 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Pranavi
Top achievements
Rank 1
Pranavi asked on 30 Jul 2013, 12:03 PM
Hello,
I need code sample for to click event for customer textblock for silverlight app.it will open customers.I added code 

SilverlightApp app = ActiveBrowser.SilverlightApps()[0];
             
TextBlock tx = app.Find.ByExpression(new XamlFindExpression("XamlTag=radribbontab,automationid=tabAccounting,|,XamlPath=/grid[name=RootPanel]/grid[name=HeaderPanel]/contentpresenter[name=HeaderElement]/grid[0]/textblock[0]")).As<TextBlock>();
 Assert.IsNotNull(tx);
tx.Wait.ForExists(10000);
tx.User.Click(MouseClickType.LeftClick);
but it's not working.As<TextBlock>Here we have to give my app textblock name or just TextBlock.

3 Answers, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 01 Aug 2013, 09:14 AM
Hi Pranavi,

Thank you for contacting us.

Every attribute in the find expression must be between double quotes. Your find expression should look like:

TextBlock tx = app.Find.ByExpression(new XamlFindExpression("XamlTag=radribbontab","automationid=tabAccounting","|","XamlPath=/grid[name=RootPanel]/grid[name=HeaderPanel]/contentpresenter[name=HeaderElement]/grid[0]/textblock[0]")).As<TextBlock>();

Try this out and let me know if it helps.

Regards,
Boyan Boev
Telerik
We've released our first-ever public Test Studio BETA! Download the BETA, install it,
and send us your feedback! Expires mid-August!
0
Pranavi
Top achievements
Rank 1
answered on 01 Aug 2013, 12:03 PM
Thank You,
I wrote code same as u told
 TextBlocktxb=app.Find.ByExpression(newXamlFindExpression("XamlTag=radpanelbaritem,automationid=Company_Customer_List","|","XamlPath=/grid[name=RootElement]/grid[name=HeaderRow]/contentpresenter[name=Header]/stackpanel[0]/textblock[0]")).As<TextBlock();.
But it's not working.am getting this error "Object reference not set to an instance of an object"

can we write using any other popertiy tell me that also.
0
Boyan Boev
Telerik team
answered on 05 Aug 2013, 08:49 AM
Hi Pranavi,

I am sorry to hear you are still experiencing this issue.

In order to investigate this issue further please send us a screen shot of the DOM structure so we can try to give you the proper code.

You can also grant us access to your application so we can reproduce the issue on our end and give you a solution. 

If it is not possible to grant us access to your application, please take a Fiddler trace and attach it to a support ticket in a zip file. You can capture a Fiddler trace using FiddlerCap

Hope to hear from you soon.

Regards,
Boyan Boev
Telerik
We've released our first-ever public Test Studio BETA! Download the BETA, install it,
and send us your feedback! Expires mid-August!
Tags
General Discussions
Asked by
Pranavi
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Pranavi
Top achievements
Rank 1
Share this question
or