Jump to content

Recommended Posts

Posted

So for the first screen the html  for the Next Button appears like this 

<input name="command" class="btn btn-primary" type="submit" value="Next">

And I created this function to click a button 

Func ClickIEButtonContaining($ButtonName)

For $oButton In $oButtons
    ;~ Check if Button InnerText equals Log In and perform an action.
    ;~ Uncomment the _IEAction line below to submit the form.
    If $oButton.InnerText = $ButtonName    Then
       if @Error then
          ConsoleWrite(@CRLF & "Error finding " & $ButtonName &  " button")

          Endif
        MsgBox(64, ' Button Found', 'Button found with value: ' & $oButton.InnerText, 2)
        Sleep(2500)
            ConsoleWrite(@CRLF & "Clicking button containing: " & $ButtonName)

        _IEAction($oButton, 'click')
        ExitLoop
        Sleep(4000)
    EndIf
 Next

EndFunc

However on the next page the same Next Button appears with this HTML 

<input name="command" class="btn btn-primary" type="submit" value="Next">

however the exact same code doesn't work on the 2nd page after clicking next  

So I guess my question is why isn't the below code working? 

 

;****************************************Click Next ********************************************/
Global $oButtons = _IETagNameGetCollection($oIE, "Button")
;below function in Generic Fucntions
ClickIEButtonContaining("Next")


ConsoleWrite(@CRLF & "First next button")

  ;/****************************End*************************************************************/

 ;/****************************Due Digilgence Screen***************************************/
Sleep(8000)

_IELoadWait($oIE)
ClickIEButtonContaining("Next")
exit

 

Posted (edited)
1 hour ago, Subz said:

What is the "Button" tag, it should be "input"?  Why not use _IEGetObjByName since both names are the same?

First i tried an IEACTIon on the command tab which just clicked the Previous button (rather than the next) 

So I tried looping through them with

;Click Next
Sleep(8000)


ConsoleWrite("Starting for loop for 2nd next button")
$oButtons = _IETagNameGetCollection($oIE, "command")
Sleep(4000)
;below function in Generic Fucntions
For $oButton In $oButtons
    ;~ Check if Button InnerText equals Log In and perform an action.
    ;~ Uncomment the _IEAction line below to submit the form.
    If $oButton.InnerText = "Next"     Then
       if @Error then
          ConsoleWrite(@CRLF & "Error finding Next input")

          Endif
        MsgBox(64, ' Button Found', 'Button found with value: ' & $oButton.InnerText, 2)
        Sleep(2500)
            ConsoleWrite(@CRLF & "Clicking button containing: Next" )

        _IEAction($oButton, 'click')
        ExitLoop
        Sleep(4000)
    EndIf
 Next

And console ouput I get is 

Clicking button containing: Next
$ObjID equals the following: 
$ObjID equals the following: 
$ObjID equals the following: 
$ObjID equals the following: 
$ObjID equals the following: 
$ObjID equals the following: 
$ObjID equals the following: 
$ObjID equals the following: Starting for loop for 2nd next button>Exit code: 0    Time: 290.8

It doesn't seem to hit the For loop and remains on the same page 

Edited by CaptainBeardsEyesBeard
Posted

You need to understand what tags, attributes are for example tags are in the format <input ../> <div ../> <a .../>, attributes appear after the tag for example <tag name="command" id="Id1" class="cssClass" ..>

So you can't use _IETagNameGetCollection to get attributes

As I mentioned above id and name can be called using _IEGetObjById, _IEGetObjByName for example the following should work (as long as no other tag has an attribute name="command"

$oButton = _IEGetObjByName($oIE, "command")
_IEAction($oButton, "click")

If you wanted to use tag collection then you would need to use something like:

ConsoleWrite("Starting for loop for 2nd next button" & @CRLF)
$oButtons = _IETagNameGetCollection($oIE, "input")
Sleep(4000)
If IsObj($oButtons) Then
    For $oButton In $oButtons
        If $oButton.getAttribute("value") = "Next" Then
            MsgBox(64, ' Button Found', 'Button found with value: ' & $oButton.getAttribute("value"), 2)
            _IEAction($oButton, 'click')
            ExitLoop
        EndIf
    Next
EndIf

 

Posted

That's great that worked  

I don't suppose you could have a look at how would I send text to this html as well?

 

<input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" placeholder="Select a practice area" style="width: 532px;">

I have tried using the below for loop and changing the innertext bracket to outertext and value to no avail 

$oButtons = _IETagNameGetCollection($oIE, "input")
Sleep(4000)

If IsObj($oButtons) Then
    For $oButton In $oButtons
        If $oButton.getAttribute("innertext") = "Select a practice area" Then
            MsgBox(64, ' Button Found', 'Button found with value: ' & $oButton.getAttribute("value"), 2)
      _IEFormElementSetValue($oButton, "BAG - Co Comm Bristol" )
            ExitLoop
        EndIf
    Next
EndIf

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...