Referencing Elements in Repository when executing methods on VisualFind

4 posts, 0 answers
  1. Rory
    Rory avatar
    16 posts
    Member since:
    Jun 2011

    Posted 24 Jun Link to this post

    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?

  2. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    251 posts

    Posted 29 Jun Link to this post

    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!
  3. Rory
    Rory avatar
    16 posts
    Member since:
    Jun 2011

    Posted 29 Jun in reply to Elena Tsvetkova Link to this post

    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.

  4. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    251 posts

    Posted 04 Jul Link to this post

    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!
Back to Top