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

Referencing Elements in Repository when executing methods on VisualFind

3 Answers 69 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rory
Top achievements
Rank 1
Rory asked on 24 Jun 2016, 09:46 PM

Greetings,

I'm using a coded step to extract the text from a RichTextBox control in WPF and set an extraction for later comparison. Since the RichTextBox is already identified by a named Element in the Elements Repository, I'd like to lookup the element by name there, then use the element's find expression to create a new XamlFindExpression to give to the Find.ByExpression method. This way I can avoid duplicating the logic.

Is this possible, or is the duplicated expression the only way?

3 Answers, 1 is accepted

Sort by
0
Elena
Telerik team
answered on 29 Jun 2016, 03:17 PM
Hello Rory,

Thank you for contacting Telerik Support Team. 

As of what you explain I understand the element is already listed in your element explorer which means it is included in the Pages file and you could access it from there. What you should use is similar to the below row of code: 

Pages.WPFApplication.RichTextBox.Text();

Please let me know if that suits your query. Otherwise elaborate more on what you require. Thank you! 

I am looking forward to hearing from you. 

Regards,
Elena Tsvetkova
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Rory
Top achievements
Rank 1
answered on 30 Jun 2016, 02:31 AM

Thanks again, Elena -

The code you posted was close, but it gave me the clue on what was intended. The Pages.g.cs file is generated and includes all the elements in the repository as properties. The WPF test step includes an instance of this class via the "Applications" property. The property itself appears to be an instance of XamlFindExpression, which needs to be passed to the Find method, like so:

var expr = Applications.AppName.WindowName.Expressions.RichTextBoxElementName;
var rtb = ActiveApplication.MainWindow.Find.ByExpression(expr);

Note: one problem using the "Applications" instance is that with a large number of elements, Intellisense in the code editor appears to fail. To find the names of the generated properties AppName and WindowName, I needed to load the compiled assembly in a tool like dotPeek and reflect on the members.

0
Elena
Telerik team
answered on 04 Jul 2016, 01:16 PM
Hi Rory,

I am glad to hear you have found the right direction although my code was quite generic. The main idea was that you could use the Pages file like you have done already. The IntelliSence issue you have noticed turned out to be quite complex unfortunately. We are aware of it but we are still investigating. We managed to fix some of the related issues but still there is place for improvement. 

Thank you for the valuable feedback though and please do not hesitate to contact Telerik Support Team in case of any future inquiries. 

Regards,
Elena Tsvetkova
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Rory
Top achievements
Rank 1
Answers by
Elena
Telerik team
Rory
Top achievements
Rank 1
Share this question
or