Jump to content
jasontj

Fill in and submit a form

Recommended Posts

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

 

 

 

 

Share this post


Link to post
Share on other sites
jasontj

I'm only using ff.au3 because that's all I know about.  I'd love to try something new.  What are my options?

I'm still kinda new at this.  Any help on the code to do the _ffxpath would be much appreciated.

Thanks,
Jason

 

Share this post


Link to post
Share on other sites
jasontj

I was able to submit the form with this:

_FFClick("ctl00_ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder2_ContentPlaceHolder2_btnSearch","id")

 

But I just can't get the value of the "Defendant Name" to populate.

Share this post


Link to post
Share on other sites
Danp2

Have you tried this?

_FFXPath("//input[@id='ctl00_ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder2_ContentPlaceHolder2_tabSearch_tabCriminal_txtCrimDefendant']")
_FFCmd("FFau3.xpath.value='Smith, John'")

If that doesn't work, try changing "//input" to "//form/input".

Share this post


Link to post
Share on other sites
Danp2
37 minutes ago, jasontj said:

I'm only using ff.au3 because that's all I know about.  I'd love to try something new.  What are my options?

If you want to continue using FF.au3, then you are stuck using an older version of FireFox due to the use of MozRepl, which isn't available as a WebExtension.

Other alternatives would be the Webdriver UDF (see my signature) or IUIAutomation.

Share this post


Link to post
Share on other sites
jasontj

Thanks.  I will give the new stuff a try.  I need to be able to stay current with my scripts.

I tried the couple of things you said.  I tried it both ways.  Below is the response.  It doesn't fill in the data.

__FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//form/input[@id='ctl00_ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder2_ContentPlaceHolder2_tabSearch_tabCriminal_txtCrimDefendant']",FFau3.WCD,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;}catch(e){'_FFXPath_Error: '+e;};
__FFRecv: 
__FFSend: try{FFau3.xpath.value='Smith, John'}catch(e){'_FFCmd_Err';};
__FFRecv: _FFCmd_Err

Share this post


Link to post
Share on other sites
jasontj

Does it matter that the website is using iFrames?

Share this post


Link to post
Share on other sites
Danp2

Generally, the answer would be Yes. However, it doesn't appear to me that the input form is within an iframe, so you should be fine by ignoring them.

Plus, you mentioned above that you were able to click the button on the same form, so you should be ok.

Share this post


Link to post
Share on other sites
jasontj

I've had the values populate a couple times, but I don't know why they don't work all of the time.  I'm about done for the day.  I will take a break and try again tomorrow.  Thanks very much for your help.  I'll let you know if I get it working.

I'll also give the new stuff a shot on my next script.   Then I'll begin converting all my old ones.

 

 

Share this post


Link to post
Share on other sites
Danp2

There are events attached to the input element. You will likely need to playing with triggering the blur / focus events using _FFDispatchEvent.

Share this post


Link to post
Share on other sites
jasontj

Here is the field.   I'm at a loss here to make this work.

<input name="ctl00$ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder2$ContentPlaceHolder2$tabSearch$tabCriminal$txtCrimDefendant" maxlength="70" id="ctl00_ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder2_ContentPlaceHolder2_tabSearch_tabCriminal_txtCrimDefendant" onblur="showDefendantFilter(this, 'tblDefendantFilter');" style="width:320px;" class="DCO_Watermark_Text" autocomplete="off" type="text">

Share this post


Link to post
Share on other sites
Danp2
_FFXPath("//input[@id='ctl00_ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder2_ContentPlaceHolder2_tabSearch_tabCriminal_txtCrimDefendant']")
_FFDispatchEvent('FFau3.xpath', 'focus')
_FFCmd("FFau3.xpath.value='Smith, John'")

 

Share this post


Link to post
Share on other sites
jasontj

Ok, now it's making a lot more sense.  That works and I understand.  Thanks so much for your help.

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

  • Similar Content

    • ademon
      By ademon
      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?

    • dadalt95
      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!
    • Gowrisankar
      By Gowrisankar
      Hello everyone,
      I'm trying to pass values to elements in a website.
      The elements are present within a table, which is again present within a table, which is inside a form.
      I tried to read the form, tables, etc., but with no results. It appears to me that the elements, tables, form, etc., were not read at all.
      The following is what I tried. Please guide me.
      ;I tried the following to read the tables into arrays #include <IE.au3> #include <MsgBoxConstants.au3> Local $oIE = _IECreate() _IENavigate($oIE, "---- URL HERE ----") _IELoadWait($oIE) $o_Table = _IETableGetCollection ($oIE) $i_NumTables = @extended For $i = 0 To $i_NumTables - 1 Step 1 $o_Table_Temp2 = _IETableGetCollection ($oIE, $i) $a_TableData = _IETableWriteToArray ($o_Table_Temp2) _ArrayDisplay($a_TableData) Next  
      ;I tried the following code to pass value to the field #include <IE.au3> #include <MsgBoxConstants.au3> Local $oIE = _IECreate() _IENavigate($oIE, "---- URL HERE ----", 0) _IELoadWait($oIE) Local $oForm = _IEFormGetObjByName($oIE, "default") Local $oField = _IEFormElementGetObjByName($oForm, "tGroup") _IEFormElementSetValue($oField, "---- VALUE HERE ----")  
      The following is the html view of the website and the highlighted field is the one that I want to pass values to. Since this is an official website, I can't share the exact url.

    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening guys ( almost good night here in Italy )  
      How are you? Hop you're fine  
      I'm trying to do a Login Form ( I did, but I'm missing something in the management ), that allows the user to login when the script is launched, and, when the main GUI is opened, the user can Logout and Login with another username and password.
      The username and password "checking" I do is done by a text file, which in there are username and password, crypted through _Crypt_EncryptData().
      The "issue" I'm having at the moment, is to manage the Login form when the user hasn't already done the login, and so, the main GUI is not visible, but is created...
      I create the main GUI after the Login form... I tried with WinActive, WinGetState, but nothing changed ( even at the first Login, the script says ( through a MsgBox ) that the Win does exists ( or is active... ) and, as I want, it is not shown again...

      I really don't know If I missed something, or, I don't know...
      I'm going crazy for this thing...
      If someone could help me, I'd really appreaciate it!
      Thanks for the reading
      #Region ### START Koda GUI section ### Form=C:\Users\Portatile-60\Documents\Documenti Lavoro\AutoIt\Gestione_Magazzino_v2\form_Login.kxf Global $form_Login = GUICreate("Effettua il Login per continuare:", 405, 120, @DesktopWidth/2 - 202.5, @DesktopHeight/2 - 150) ; 302, 218 GUISetOnEvent($GUI_EVENT_CLOSE, "GUIDeleteLogin") Global $combo_Username = GUICtrlCreateCombo("Di Muro Francesco", 104, 64, 217, 25) GUICtrlSetFont(-1, 10, 400, 0, "Arial") GUICtrlSetData($combo_Username, "somedata") Global $input_Password = GUICtrlCreateInput("", 104, 89, 217, 25, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) GUICtrlSetFont(-1, 10, 400, 0, "Arial") $button_VerificaDati = GUICtrlCreateButton("", 328, 66, 42, 42, $BS_ICON) GUICtrlSetImage(-1, "C:\Users\Portatile-60\Documents\Documenti Lavoro\AutoIt\Gestione_Magazzino_v2\Icone\icon_check.ico", -1) GUICtrlSetOnEvent($button_VerificaDati, "CheckLogin") $label_Titolo = GUICtrlCreateLabel("Login", 167, 14, 71, 33) GUICtrlSetFont(-1, 18, 800, 0, "Arial") $label_Username = GUICtrlCreateLabel("Username :", 24, 64, 76, 20) GUICtrlSetFont(-1, 10, 800, 0, "Arial") $label_Password = GUICtrlCreateLabel("Password :", 24, 89, 73, 20) GUICtrlSetFont(-1, 10, 800, 0, "Arial") #EndRegion ### END Koda GUI section ### Func CheckLogin() Local $sUsername = GUICtrlRead($combo_Username) Local $sPassword = GUICtrlRead($input_Password) MsgBox($MB_ICONINFORMATION, "", "Username: " & $sUsername & @CRLF & "Password: " & $sPassword) Local $sFileUtenti = @ScriptDir & "\utenti.txt" If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante la lettura del file!") Exit Else Local $hFileUtenti = FileOpen($sFileUtenti, $FO_READ) If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante l'apertura del file " & $sFileUtenti & "." & @CRLF & "Errore: " & @error) Else Local $sDatiUtente, $aDatiUtente Local $bUtenteTrovato = False Local $iLinea = 1 Local $sControlloWin = "" Local $sWin = WinGetState($form_GestioneMagazzino) MsgBox($MB_ICONINFORMATION, "", $sWin) If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante la verifica della GUI attiva." & @CRLF & "Errore: " & @error) EndIf If($sWin == 5) Then MsgBox($MB_ICONINFORMATION, "", "La GUI esiste!") Do $sDatiUtente = FileReadLine($hFileUtenti, $iLinea) $aDatiUtente = StringSplit($sDatiUtente, "|", $STR_NOCOUNT) If(BinaryToString(_Crypt_DecryptData($aDatiUtente[0], "CRYPT", $CALG_RC4)) = $sUsername And BinaryToString(_Crypt_DecryptData($aDatiUtente[1], "CRYPT", $CALG_RC4)) = $sPassword) Then $sControlloWin = "ESISTE" $bUtenteTrovato = True ExitLoop Else $iLinea+=1 If($sDatiUtente = "" And $bUtenteTrovato = False) Then MsgBox($MB_ICONWARNING, "Attenzione!", "Username o Password errati.") ExitLoop EndIf EndIf Until $bUtenteTrovato = True Else MsgBox($MB_ICONINFORMATION, "", "La GUI esiste!") Do $sDatiUtente = FileReadLine($hFileUtenti, $iLinea) $aDatiUtente = StringSplit($sDatiUtente, "|", $STR_NOCOUNT) If(BinaryToString(_Crypt_DecryptData($aDatiUtente[0], "CRYPT", $CALG_RC4)) = $sUsername And BinaryToString(_Crypt_DecryptData($aDatiUtente[1], "CRYPT", $CALG_RC4)) = $sPassword) Then $sControlloWin = "NON ESISTE" $bUtenteTrovato = True ExitLoop Else $iLinea+=1 If($sDatiUtente = "" And $bUtenteTrovato = False) Then MsgBox($MB_ICONWARNING, "Attenzione!", "Username o Password errati.") ExitLoop EndIf EndIf Until $bUtenteTrovato = True EndIf If($sControlloWin = "ESISTE") Then MsgBox($MB_ICONINFORMATION, "Login effettuato!", "Hai effettuato l'accesso come: " & @CRLF & $sUsername & ".") ; Setta come "non-cliccabile" il bottone di Login GUICtrlSetState($button_Login, $GUI_DISABLE) GUICtrlSetState($button_VisualizzaGiacenze, $GUI_ENABLE) GUICtrlSetState($button_AggiungiProdotto, $GUI_ENABLE) GUICtrlSetState($button_PrelevaProdotto, $GUI_ENABLE) GUICtrlSetState($button_RicercaProdotto, $GUI_ENABLE) GUICtrlSetState($button_CreaDDT, $GUI_ENABLE) GUICtrlSetState($button_MostraGiacenzeAZero, $GUI_ENABLE) GUICtrlSetState($combo_Magazzino, $GUI_ENABLE) GUICtrlSetState($button_Logout, $GUI_ENABLE) ; Setta come "non-cliccabile" il bottone di Login GUICtrlSetState($button_Login, $GUI_DISABLE) ; Setta l'utente che ha effettuato l'accesso nella label $label_CaptionUtente GUICtrlSetData($label_CaptionUtente, $sUsername) ; "Distruggi" la GUI Login GUIDelete($form_Login) FileClose($hFileUtenti) Else MsgBox($MB_ICONINFORMATION, "", "La GUI non esiste!") MsgBox($MB_ICONINFORMATION, "Login effettuato!", "Hai effettuato l'accesso come: " & @CRLF & $sUsername & ".") ; Mostra la GUI Principale GUISetState(@SW_SHOW, $form_GestioneMagazzino) ; Setta come "non-cliccabile" il bottone di Login GUICtrlSetState($button_Login, $GUI_DISABLE) ; Setta l'utente che ha effettuato l'accesso nella label $label_CaptionUtente GUICtrlSetData($label_CaptionUtente, $sUsername) ; "Distruggi" la GUI Login GUIDelete($form_Login) FileClose($hFileUtenti) EndIf EndIf EndIf EndFunc Func Logout() GUICtrlSetData($label_CaptionUtente, "") MsgBox($MB_ICONINFORMATION, "Logout effettuato!", "Effettua nuovamente il Login per utilizzare il programma.") ; Disabilita tutti i bottoni della GUI Principale GUICtrlSetState($button_VisualizzaGiacenze, $GUI_DISABLE) GUICtrlSetState($button_AggiungiProdotto, $GUI_DISABLE) GUICtrlSetState($button_PrelevaProdotto, $GUI_DISABLE) GUICtrlSetState($button_RicercaProdotto, $GUI_DISABLE) GUICtrlSetState($button_CreaDDT, $GUI_DISABLE) GUICtrlSetState($button_MostraGiacenzeAZero, $GUI_DISABLE) GUICtrlSetState($combo_Magazzino, $GUI_DISABLE) GUICtrlSetState($button_Logout, $GUI_DISABLE) ; Abilita il Login GUICtrlSetState($button_Login, $GUI_ENABLE) EndFunc EDIT:
      Solved, making an "integrated" Login form... 
    • mutleey
      By mutleey
      Hello everybody, I have a problem here ... I need to generate a form of sale and print quality using the form I could do is not getting good, I created a window without borders with the fields I need, then use the function _ScreenCapture_CaptureWnd () to generate a print of this window and send the image to the printer using the UDF printMGv2.au3, the problem is that to get a good quality I would have to create a huge window to get the print, any suggestions to print this form with a good quality?
      thank you...
      example of the form it takes:
       

×