none
AutomationElement to AutomationPeer or Other Possible Solution RRS feed

  • Question

  • I'm mainly using AutomationPeers for my unit testing that I am doing and several controls that I test have buttons on them that are invoked and cause a new form to pop up.  I've handled this by created a method that will start on another thread looking for the automationid and closing the window when it finds it.  I'm using an AutomationElement and WindowPattern to get this closed.  It's come to the point where I actually need to verify something on that form that pops up.  I know you can't directly cast AutomationPeer into AutomationElement and that UIElementAutomationPeer.CreatePeerForElement() does not work on AutomationElements.  My question is: Is there any way to do this and if so, how and if not then what would be a suggestion to manipulate this window.  I'm think I may just have to use AutomationElements and their corresponding patterns.
    Monday, December 27, 2010 5:21 PM

All replies

  • Hi, Chris,

    I think you are on the right track.  AutomationPeer is used from inside the application that is being made accessible, but the unit test itself would use AutomationElements directly, since it is interacting with your application from the outside

    We certainly designed AutomationElement to be used directly, so I think it should be straightforward, but if you have a specific question, please ask.

    Thanks,
    Michael


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Wednesday, January 5, 2011 9:38 PM