none
Error al utilizar el procedimiento invoke con Uiautomationclient y VBA RRS feed

  • Pregunta

  • Hola a todos,

    Soy nuevo en el mundo de la automatizacion de interfases de usuario. Estoy desarrollando un codigo en VBA para darle click a un boton en una aplicacion que se encuentra en la nube. El codigo que estoy utilizando es el siguiente. Cuando se va a ejecutar la opcion oinvokePattern.invoke me sale el siguiente error: Variable de objeto o bloque With no establecido. Por lo que he podido investigar el boton que quiere ejecutar esta dentro de un "pane". Les agradezco cualquier ayuda que me puedan brindar. Gracias!

    requirementGroup = Array("TFormSeleccionPago1", "TPanel", "TAdvSmoothPanel", "Siguiente")
    idTypeGroup = Array("ClsName", "ClsName", "ClsName", "Name")
    valueFound = executeOperation("click", requirementGroup, idTypeGroup)

    Function executeOperation(ByVal operationType As String, ByVal requirementGroup As Variant, ByVal idTypeGroup As Variant, Optional valueToWrite As String) As String

    Dim oInvokePattern As UIAutomationClient.IUIAutomationInvokePattern
    Dim oPattern As UIAutomationClient.IUIAutomationLegacyIAccessiblePattern
    Dim oGridPattern As UIAutomationClient.IUIAutomationGridPattern 

    If UBound(requirementGroup) >= 0 Then
        Set MyElement1 = parentElement.FindFirst(TreeScope_Children, PropCondition(oAutomation, requirementGroup(0), idTypeGroup(0)))
        odd = True
    End If

    If UBound(requirementGroup) >= 1 Then
        Set MyElement2 = MyElement1.FindFirst(TreeScope_Children, PropCondition(oAutomation, requirementGroup(1), idTypeGroup(1)))
        odd = False
    End If

    If UBound(requirementGroup) >= 2 Then
        Set MyElement1 = MyElement2.FindFirst(TreeScope_Children, PropCondition(oAutomation, requirementGroup(2), idTypeGroup(2)))
        odd = True
    End If

    If UBound(requirementGroup) >= 3 Then
        Set MyElement2 = MyElement1.FindFirst(TreeScope_Children, PropCondition(oAutomation, requirementGroup(3), idTypeGroup(3)))
        odd = False
    End If

    If UBound(requirementGroup) >= 4 Then
        Set MyElement1 = MyElement2.FindFirst(TreeScope_Children, PropCondition(oAutomation, requirementGroup(4), idTypeGroup(4)))
        odd = True
    End If

    If UBound(requirementGroup) >= 5 Then
        Set MyElement2 = MyElement1.FindFirst(TreeScope_Children, PropCondition(oAutomation, requirementGroup(5), idTypeGroup(5)))
        odd = False
    End If

    If odd = False Then
           Set oInvokePattern = MyElement2.GetCurrentPattern(UIAutomationClient.UIA_AccessKeyPropertyId)
    Else
           Set oInvokePattern = MyElement1.GetCurrentPattern(UIAutomationClient.UIA_ValuePatternId)
    End If
                oInvokePattern.Invoke

    End function

    Function PropCondition(UiAutomation As CUIAutomation, ByVal Requirement As String, ByVal idType As String) As UIAutomationClient.IUIAutomationCondition

    Select Case idType
        Case "Name"
            Set PropCondition = UiAutomation.CreatePropertyCondition(UIAutomationClient.UIA_NamePropertyId, Requirement)
        Case "AutoID"
            Set PropCondition = UiAutomation.CreatePropertyCondition(UIAutomationClient.UIA_AutomationIdPropertyId, Requirement)
        Case "ClsName"
            Set PropCondition = UiAutomation.CreatePropertyCondition(UIAutomationClient.UIA_ClassNamePropertyId, Requirement)
        Case "LoczCon"
            Set PropCondition = UiAutomation.CreatePropertyCondition(UIAutomationClient.UIA_LocalizedControlTypePropertyId, Requirement)
    End Select
    End Function

    martes, 16 de octubre de 2018 16:03