Forum Discussion

salley's avatar
salley
Frequent Contributor
8 years ago

how to findallchildren and click during the runtime

Hi experts,

i've a web screen with questionnaire and i need to click on no to all during the run time, can that be handled through script, can somebody provide me a sample script.  type is radio button. i want to handle it through scripts because questionnaire changes each run time. they're not static

thanks

  • I'm not super familiar with VBScript but it looks like this is because of how your setting sRadioButtons.

     

    The result of FindAllChildren is an array so you need to work with it as such. Try this:

     

    function findallchild
      Dim PropName, PropValues,i,sRadioButtons
      PropNames=Array("ObjectType","ObjectLabel")
      PropValues=Array("RadioButton","No")
      Set sPage=Sys.Browser("iexplore").Page("http://me-aptweb1/Affiliation/Questionnaire.aspx")
      sRadioButtons=sPage.FindAllChildren(PropNames,PropValues,100)
      If UBound (sRadioButtons)>=0 Then
        For i = 0 To UBound(sRadioButtons)
            sRadioButtons(i).Click
        Next
        Log.Message "Total objects found: " & (UBound(sRadioButtons) + 1)
      End If
    End Function
  • cunderw's avatar
    cunderw
    Community Hero

    Yes, this is absolutely doable. 

     

    Some pseudo code below. Note you will have to determine properties / values for the no radio buttons.

     

    var buttons = <your page>.FindAllChildren(<props>,<vals>,100);
    for(let i = 0; i < buttons.length; i++) {
      buttons[i].Click();
    }
    • salley's avatar
      salley
      Frequent Contributor

      Thanks,

      I'm trying to simulate that using VBscript, and i just can't get it right, can you please take a look. I also attached a screen shot.

       

      function findallchild
      Dim PropName, PropValues,i
      PropNames=Array("ObjectType","ObjectLabel")
      PropValues=Array("RadioButton","No")
      Set sPage=Sys.Browser("iexplore").Page("http://me-aptweb1/Affiliation/Questionnaire.aspx")
      Set sRadioButtons=sPage.FindAllChildren(PropNames,PropValues,100)
      If UBound (sRadioButtons)>=0 Then
      For i = 0 To UBound(sRadioButtons)
      sRadioButtons(i).Click
      Next
      Log.Message "Total objects found: " & (UBound(sRadioButtons) + 1)
      End If
      End Function

      • cunderw's avatar
        cunderw
        Community Hero

        I'm not super familiar with VBScript but it looks like this is because of how your setting sRadioButtons.

         

        The result of FindAllChildren is an array so you need to work with it as such. Try this:

         

        function findallchild
          Dim PropName, PropValues,i,sRadioButtons
          PropNames=Array("ObjectType","ObjectLabel")
          PropValues=Array("RadioButton","No")
          Set sPage=Sys.Browser("iexplore").Page("http://me-aptweb1/Affiliation/Questionnaire.aspx")
          sRadioButtons=sPage.FindAllChildren(PropNames,PropValues,100)
          If UBound (sRadioButtons)>=0 Then
            For i = 0 To UBound(sRadioButtons)
                sRadioButtons(i).Click
            Next
            Log.Message "Total objects found: " & (UBound(sRadioButtons) + 1)
          End If
        End Function