Jump to content
Sign in to follow this  
ademon

webdriver - more than one submit

Recommended Posts

Hi. I can not automate the click at a button, because there are three of them exactly in the source page.

Imagine you have this html source code:

<div class="submit"><span class="button btnDefault"><span><input type="submit" value="Search" /></span></span></div>

How could I select just one element, and do click as an action on it?

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@type='submit'][@value='Search']")

_WD_ElementAction($sSession, $sElement, 'click')

That just do not work.

Any ideas?

submits.PNG

Share this post


Link to post
Share on other sites

You can get an array of submit elements then access to correct one in the array.

 

Saludos

Share this post


Link to post
Share on other sites
31 minutes ago, Danyfirex said:

You can get an array of submit elements then access to correct one in the array.

 

Saludos

Gracias Danyfirex, I think I understand what you mean but I do not know how to code it

I have tried to do this:

Local $aVar[3]
    _ArrayAdd ($aVar,_WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@type='submit'][@value='Search']"))
    _ArrayAdd ($aVar,_WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@type='submit'][@value='Search']"))
    _ArrayAdd ($aVar,_WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@type='submit'][@value='Search']"))

    MsgBox($MB_SYSTEMMODAL, "FINaaa", $aVar[2] )
    _WD_ElementAction($sSession, $aVar[2], 'click')

but with out result.

Share this post


Link to post
Share on other sites

I meant this:

Local $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@type='submit'][@value='Search']","",True)
_ArrayDisplay($aElements)

Saludos

Share this post


Link to post
Share on other sites
14 minutes ago, Danyfirex said:

I meant this:

Local $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@type='submit'][@value='Search']","",True)
_ArrayDisplay($aElements)

Saludos

Sounds good! Let see if I can use it...

array.PNG

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By XinYoung
      Hello again 
      I need to click this Submit button, but it's in a lightbox and has no ID (i think) and I can't figure out a way to target it. _IEFormSubmit doesn't work.

       
      Thank you
    • By jasontj
      Hello.  I'm working on converting another script from IE to Firefox.  I can't seem to get a handle on the field "Defendant" to fill in a last, first name on this page:
      http://www.hcdistrictclerk.com/Edocs/Public/Search.aspx?Tab=tabCriminal
      I also can't seem to submit the form.   I've tried the code below... stuff may be commented out that I have tested.
       
          _FFOpenUrl("http://www.hcdistrictclerk.com/Edocs/Public/Search.aspx?Tab=tabCriminal")    
          _FFLoadWait()
          $oTextFN = _FSObjGet("ctl00_ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder2_ContentPlaceHolder2_tabSearch_tabCriminal_txtCrimDefendant", "ID")
          
          _FFObj($oTextFN, "value", "Smith, John")    
          $subButton = _FFObjGet("ctl00$ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder2$ContentPlaceHolder2$btnSearch", "name")
          _FFClick($subButton)
          _FFLoadWait()
          
      ;    _FFFormSubmit()
      ;    _FFLoadWait()
       
      Any help from the experts on here would be greatly appreciated.  
       
      Jason
       
       
       
       
    • By dadalt95
      Perform a simple google search!
      The script below works fine until fill the google form!
      What I can't find is how to submit the form, tried a couple of ways and none of them worked.

       
      #include <IE.au3> $oIE = _IECreate ("www.google.com") $o_form = _IEFormGetObjByName ($oIE, "f") $o_login = _IEFormElementGetObjByName ($o_form, "q") $username = "80251369" _IEFormElementSetValue ($o_login, $username) $o_numer = _IEGetObjByName($o_form, "btnK") _IEAction ($o_numer, "click")  
      The code runs without any problem.
      I don't know how to proceed!
      Thanks in advance!
    • By boy233
      Hello, 
      How do I select the submit?
      Anybody know?!
      <form method="post" action="register.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="form1"> .... .... <input type="submit" name="btnConfirm" value="Confirm" id="btnConfirm" disabled="disabled" class="aspNetDisabled Button" /> &nbsp;&nbsp; .... .... <input type="submit" name="btnQuery" value="Query" id="btnQuery" disabled="disabled" class="aspNetDisabled Button" /> &nbsp;&nbsp; </form>  
    • By BobSherman
      I am attempting to enter the logon ID and password into the form below and submit it.
      But, I am experiencing an error in IE.au3 whether I use _IEAction to submit a click (which does submit the form) or _IEFormSubmit (which does not submit the form before it errors out).
      The form seems rather simple:
      <form method="post" action="logon_submit.php">
                             <input type="hidden" name="visit" value="sRhvMItOu1hNV_y9t4iB7xhns2UJ0pUIYmpJyy3CivjvGYv0ST1QHY40QP9H5UPTqonadminkin_65dvtXxSIXDPwyFFI6WPVQFmgFtba8vW3OH">
      <table width="100%" border="0" cellpadding="0" align="center" cellspacing="0">
                          <tr>
                            <td valign=top><table width="100%" border="0" cellpadding="4" cellspacing="1">
                                <tr>
                                  <td align="Right"><b>Username: <span class="style1">*</span></b></td>
                                  <td width="80%"><input type="TEXT" name="user" style="width: 90%;">
                                  </td>
                                </tr>
                                <tr>
                                  <td align="Right"><b>Password: <span class="style1">*</span></b></td>
                                  <td><input type="password" name="pass" style="width: 90%;">
                                  </td>
                                </tr>
                                <tr>
                                  <td align="Right">&nbsp;</td>
                                  <td><input type="submit" name="Submit" value="Submit Form">
                                  </td>
                                </tr>
                                <tr>
                                  <td align="Right">&nbsp;</td>
                                  <td><a href="resetpw.php?visit=sRhvMItOu1hNV_y9t4iB7xhns2UJ0pUIYmpJyy3CivjvGYv0ST1QHY40QP9H5UPTqonadminkin_65dvtXxSIXDPwyFFI6WPVQFmgFtba8vW3OH" class=white>Forgot your password ?</a></td>
                                </tr>
                              </table>
                                <p>&nbsp;</p>
                            </td>
                          </tr>
                        </table>
                      </form>
       
      My function to perform the logon is:
       
      Func StartUp()
         _IELinkClickByText ( $oIE, "Log On" )
         Sleep(2000)
         Local $oForm = _IEFormGetCollection($oIE)
         Local $iNumberOfForms = @extended
         For $iForm = 0 To $iNumberOfForms - 1
           $oForm = _IEFormGetCollection($oIE, $iForm)
           Local $oQuery = _IEFormElementGetCollection($oForm)
           Local $iNumberOfFormElements = @extended
           For $iElement = 0 to $iNumberOfFormElements - 1
               Local $oFormElement = _IEFormElementGetCollection($oForm, $iElement )
               If $oFormElement.name = 'user' Then
                  _IEFormElementSetValue ( $oformElement, "xxxxx", 0)
               elseif $oFormElement.name = "pass" Then
                  _IEFormElementSetValue ( $oFormElement, "yyyyy", 0)
                  ; Sleep for 2 seconds.
                  Sleep(2000)
                  Local $oSubmit = _IEGetObjByName($oIE, "Submit")
                  _IEAction($oSubmit, "click")
                  Sleep(3000)
               EndIf
            Next
         Next
      EndFunc
       

      After the submission of the form completes and goes to the next page I'm getting the following error as a popup from AutoIt:
       

      Line 970 (File "D\Program Files (x86)\AutoIt3\Include\IE.au3"):
      Case $iIndex > -1 And $iIndex < $oObject.elements.length
      Case $iIndex > -1 And $iIndex < $oObject^ ERROR
      Error: The requested actions with this object has failed.

      It's hard to imagine that such a simple form is causing so many problems.
      Any help would be appreciated.
       
       
       
×
×
  • Create New...