The online community for software testing & quality assurance professionals
 
 
Calendar   Today's Topics
Sponsors:




Lost Password?

Home
BetaSoft
Blogs
Jobs
Training
News
Links
Downloads



Software Testing >> Automated Testing

Pages: 1
elwinwildschut
Member


Reged: 10/01/02
Posts: 67
Loc: amsterdam
Windows Automation API 3.0
      #672312 - 05/22/11 02:05 PM

Anybody build a framework or is using Windows Automation API 3.0?

I tried some stuff with VBA in Excel and it all seems powerfull (but low level) and unfortunately most examples are in C# or other .NET languages when I google.

Once you make a reference to UIAutomationCore.DLL you can have a lot of fun in VBA Excel

Code:

sub test()
Dim oAutomation As New CUIAutomation ' the UI Automation API
Dim oDesktop As UIAutomationClient.IUIAutomationElement 'Reference to the root element (desktop)
Dim oTW As UIAutomationClient.IUIAutomationTreeWalker
Dim oItem As UIAutomationClient.IUIAutomationElement
Dim oCondition1 As UIAutomationClient.IUIAutomationCondition 'Used for conditional find of controls
Dim oCondition2 As UIAutomationClient.IUIAutomationCondition 'Used for conditional find of controls
Dim oCondition3 As UIAutomationClient.IUIAutomationCondition 'Used for conditional find of controls

Dim oChilds As UIAutomationClient.IUIAutomationElementArray 'Elementarray when controls are found

Set oDesktop = oAutomation.GetRootElement 'Get reference to the root element (desktop)

'Just select 2 items on the desktop
Set oCondition1 = oAutomation.CreatePropertyCondition(UIA_NamePropertyId, "Program Manager")
Set oCondition2 = oAutomation.CreatePropertyCondition(UIA_NamePropertyId, "Rekenmachine")
Set oCondition3 = oAutomation.CreateOrCondition(oCondition1, oCondition2)


Set oChilds = oDesktop.FindAll(TreeScope_Children, oCondition3)
'Dim help As Object = elementList.GetCurrentPropertyValue(AutomationElement.HelpTextProperty, True)
'If help Is AutomationElement.NotSupported Then
' help = "No help available"
'End If
'Dim helpText As String = CStr(help)


'Show all childs that where found
Debug.Print "approach 1"
For i = 0 To oChilds.Length - 1
Debug.Print i & oChilds.GetElement(i).CurrentName & oChilds.GetElement(i).CurrentClassName
' elementList is an AutomationElement.
Next
Debug.Print

'Just select all tems on the desktop
Set oCondition1 = oAutomation.CreateTrueCondition

Set oChilds = oDesktop.FindAll(TreeScope_Children, oCondition1)
'Dim help As Object = elementList.GetCurrentPropertyValue(AutomationElement.HelpTextProperty, True)
'If help Is AutomationElement.NotSupported Then
' help = "No help available"
'End If
'Dim helpText As String = CStr(help)


'Show all childs that where found
x = oDesktop.GetCurrentPropertyValue(UIA_RuntimeIdPropertyId)
Debug.Print "approach 2"
For i = 0 To oChilds.Length - 1
Debug.Print i & oChilds.GetElement(i).CurrentName & oChilds.GetElement(i).CurrentClassName & oChilds.GetElement(i).GetCurrentPropertyValue(UIA_NamePropertyId)
' elementList is an AutomationElement.
Next
Debug.Print

' Lets show all the items of the desktop with a treewalker
Set oTW = oAutomation.ControlViewWalker

'Get the first child of the desktop
Set oItem = oTW.GetFirstChildElement(oDesktop)
While Not oItem Is Nothing
Debug.Print i & oItem.CurrentName & oItem.CurrentClassName
Set oItem = oTW.GetNextSiblingElement(oItem)
Wend

End Sub



Post Extras: Print Post   Remind Me!   Notify Moderator  
Shane_MacLaughlin
Super Member


Reged: 09/22/05
Posts: 1736
Loc: Dublin, Ireland
Re: Windows Automation API 3.0 [Re: elwinwildschut]
      #672489 - 05/24/11 05:08 AM

Looks very interesting, but your application under test needs to implement the IAccesibleEx, which may or may not be the case depending on the UI libraries used to build it.

I'd be interested to hear how you get on, so any posts on your progress would be appreciated.

--------------------
My LinkedIn profile


Post Extras: Print Post   Remind Me!   Notify Moderator  
elwinwildschut
Member


Reged: 10/01/02
Posts: 67
Loc: amsterdam
Re: Windows Automation API 3.0 [Re: Shane_MacLaughlin]
      #673005 - 05/29/11 03:05 AM

For the moment I continued in AutoIT as I could not get the focus events thru VBA and the withevents keyword. Still investigating

http://www.autoitscript.com/forum/topic/...__fromsearch__1

As far as I can see most popular controls support IAccessible nowadays.

I did at least get firefox, IE, Chrome all automated for the standard HTML controls and all WIN32 controls which is what I need. Not sure if UI Automation API works natively for flash or java controls.


Post Extras: Print Post   Remind Me!   Notify Moderator  
libin1234
Newbie


Reged: 10/24/12
Posts: 11
Re: Windows Automation API 3.0 [Re: elwinwildschut]
      #719511 - 11/08/12 01:34 AM

An interesting post related to the same topic -http://mechanicalhandshake.blogspot.com/2011_01_01_archive.html

Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 7 anonymous users are browsing this forum.

Moderator:  Elfriede Dustin, AJ, Joe Strazzere 

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 8491

Rate this topic

Jump to

Contact Us | Privacy statement SQAForums

Powered by UBB.threads™ 6.5.5