Automation Beyond

Testing and Test Automation for Software Quality Assurance. Above Requirements. Beyond Expectations. Methodologies and concepts. Framework Design. Programming and Scripting. Created by Albert Gareev.

GP/QTP Automation: GUI Mapping script

Posted by Albert Gareev on 2009/09/09

All related posts: Reference Page – GP/QTP Automation 

Purpose: extract object descriptions from Dexterity Dictionary and create custom XML-based GUI Map file for QTP.

XML Service Functions reference page: Service Functions – XML (QTP, VBScript)


Option Explicit
' Purpose: Map GP Dexterity GUI into XML file
' Requirements: GP App started (don't have to login)
'Output: ".....\DexGUI.xml"

Dim GPApp, objForm, objWindow, objWndField
Dim sGPMapXML, sCurrentProduct
Dim FormIter, WinIter, FieldIter
Dim objGPMapXML, objRoot, objFormMapXML, objWndMapXML, objFldMapXML

Set GPApp = GetObject("", "Dynamics.Application")

sCurrentProduct = GPApp.CurrentProduct

'Define or parameterize your output folder here

sGPMapXML = "C:\TEMP\" & "\DexGUI.xml"
Set objGPMapXML = XMLUtil.CreateXML("DexGUI")
Set objRoot = objGPMapXML.GetRootElement

FormIter = 1
Set objForm = GPApp.GetFirstForm()
Do
 If Not (objForm is Nothing) Then
  Set objFormMapXML = CreateChildElementByName(objRoot, "Form", "")
  objFormMapXML.AddAttribute "name", objForm.GetName()
  objFormMapXML.AddAttribute "childcount", CStr(objForm.CountWindows())
  
  WinIter = 1
  Set objWindow = objForm.GetFirstWindow()
  Do
 
   If Not (objWindow is Nothing) Then
    Set objWndMapXML = CreateChildElementByName(objFormMapXML, "Window", "")
    objWndMapXML.AddAttribute "name", objWindow.GetName()
    objWndMapXML.AddAttribute "childcount", CStr(objWindow.CountFields())
    
    FieldIter = 1
    Set objWndField = objWindow.GetFirstWindowField()
    Do
 
     If Not (objWndField is Nothing) Then
      Set objFldMapXML = CreateChildElementByName(objWndMapXML, "Field", "")
      objFldMapXML.AddAttribute "name", objWndField.GetName()
      objFldMapXML.AddAttribute "id", CStr(objWndField.GetID())
     End If
    
     FieldIter = FieldIter +1
     Set objWndField = objWindow.GetNextWindowField()
 
    Loop While FieldIter <= objWindow.CountFields()
 
   End If

  Set objWindow = objForm.GetNextWindow()
  WinIter = WinIter + 1
  Loop While WinIter <= objForm.CountWindows()

 End If
 
 Set objForm = GPApp.GetNextForm()
 FormIter = FormIter + 1

Loop While FormIter <= GPApp.CountForms()

objGPMapXML.SaveFile sGPMapXML
Set GPApp = Nothing
Set objForm = Nothing
Set objWindow  = Nothing
Set objWndField = Nothing
Set objGPMapXML = Nothing
Set objRoot = Nothing
Set objFormMapXML = Nothing
Set objWndMapXML = Nothing
Set objFldMapXML = Nothing

3 Responses to “GP/QTP Automation: GUI Mapping script”

  1. [...] GP/QTP Automation: GUI Mapping script [...]

  2. [...] if they were successfully mapped with Dexterity GUI Mapping Script [...]

  3. [...] GUI Capture and Mapping [...]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>