Hi,
I have a requirement where I have to test the position of different Elements.
This position is set in our application using a Parent Cancas as container. Then our custom user controls are placed using Cancas attached properties: "Top" and "Left".
In our test scenario we tried to retrieve this value withe the following code:
But this code throw an exception:
[WPF Extension Error] Details: ArtOfTest.WebAii.Silverlight.NoSuchPropertyException: Unable to find attached property owner class 'Canvas'
bei Telerik.TestingFramework.XamlExtension.ClientServices.GetAttachedPropertyValue(AutomationProperty property, Object obj)
bei Telerik.TestingFramework.XamlExtension.ClientServices.GetRealProperty(AutomationReference reference, AutomationProperty property)
bei Telerik.TestingFramework.XamlExtension.ClientProcessor.ProcessCommand(String command)
Do I do something wrong? Is there a way to test the position of UI elements ?
Thanks.
Benoît
I have a requirement where I have to test the position of different Elements.
This position is set in our application using a Parent Cancas as container. Then our custom user controls are placed using Cancas attached properties: "Top" and "Left".
In our test scenario we tried to retrieve this value withe the following code:
var left = userControl.GetAttachedProperty<
double
>(
"Canvas"
,
"Left"
);<br>var top = userControl.GetAttachedProperty<
double
>(
"Canvas"
,
"Top"
);
But this code throw an exception:
[WPF Extension Error] Details: ArtOfTest.WebAii.Silverlight.NoSuchPropertyException: Unable to find attached property owner class 'Canvas'
bei Telerik.TestingFramework.XamlExtension.ClientServices.GetAttachedPropertyValue(AutomationProperty property, Object obj)
bei Telerik.TestingFramework.XamlExtension.ClientServices.GetRealProperty(AutomationReference reference, AutomationProperty property)
bei Telerik.TestingFramework.XamlExtension.ClientProcessor.ProcessCommand(String command)
Do I do something wrong? Is there a way to test the position of UI elements ?
Thanks.
Benoît
6 Answers, 1 is accepted
0
Lorenz
Top achievements
Rank 1
answered on 08 Dec 2014, 03:20 PM
I think it's possible to use the GetRectangle method by passing the relativeTo element (here it will be my canvas container).
This is not optimal in my case but I could be a workaround. If anybody knows a way to retrieve the Canvas.Left and Canvas.Top properties, please let know.
Thanks.
Benoît
This is not optimal in my case but I could be a workaround. If anybody knows a way to retrieve the Canvas.Left and Canvas.Top properties, please let know.
Thanks.
Benoît
0
Hi Benoit,
Your code looks correct. Could you please give us some demo or access to your application so we can try to reproduce the issue and give you a solution.
Also please double check that the property is of type double.
Hope to hear from you soon.
Regards,
Boyan Boev
Telerik
Your code looks correct. Could you please give us some demo or access to your application so we can try to reproduce the issue and give you a solution.
Also please double check that the property is of type double.
Hope to hear from you soon.
Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Test Studio Trainings
0
Lorenz
Top achievements
Rank 1
answered on 18 Dec 2014, 04:00 PM
Hi Boyan,
Please find attached a VS solution containing a small WPF application, and some UI Automation tests (in UiAutomationTest.cs):
Benoît
Please find attached a VS solution containing a small WPF application, and some UI Automation tests (in UiAutomationTest.cs):
- When_RetrieveCanvasAttachedProperties
Benoît
0
Accepted
Hi Benoit,
Thank you again for the sample.
You should use this syntax for the canvas:
Let me know if this helps.
Regards,
Boyan Boev
Telerik
Thank you again for the sample.
You should use this syntax for the canvas:
var left = textblock.GetAttachedProperty<
double
>(
"System.Windows.Controls.Canvas"
,
"Left"
);
Let me know if this helps.
Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Test Studio Trainings
0
Lorenz
Top achievements
Rank 1
answered on 05 Jan 2015, 02:03 PM
Hi Boyan,
Sorry for my late feedback.
Good news, it works with your syntax!
Kind regards,
Benoît
Sorry for my late feedback.
Good news, it works with your syntax!
Kind regards,
Benoît
0
Hello Benoit,
Glad to hear that.
If you need further help please let us know.
Regards,
Boyan Boev
Telerik
Glad to hear that.
If you need further help please let us know.
Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Test Studio Trainings