Jump to content
Sign in to follow this  
rudi

Basic help for filling upload form in browser

Recommended Posts

Hello,

usually I do Win automations, so I have no skills at all to handle HTML forms :-/

The script to catch and syntax check  the required information from Excel is done.

Now I'd like to automate the upload using this form, too:

 

http://flashcardsdeluxe.com/flashcards/Upload.aspx

  • What browser is easiest to do so? (IE, Chrome, FF)
  • The Values $DeckCode, $DeckName, $DeckDefinition shall go to their HTML form fields
  • finally "click" the button "upload flashcards"
<table width="70%" class="cssCenter" border="0">

        <tr>
        <td style="width: 1%">Deck&nbsp;Code</td>
        <td style="width: 100%"><input name="ctlDeckCode" type="text" id="ctlDeckCode" style="width:50%;" /> (no spaces allowed)</td>
        <td></td>
        </tr>
        
        <tr>
        <td style="width: 1%">Deck&nbsp;Name</td>
        <td style="width: 100%"><input name="ctlDeckName" type="text" id="ctlDeckName" style="width:50%;" /> (optional)</td>
        <td style="width: 1%" align="right"><input type="submit" name="ctlUpload" value="Upload Flashcards" id="ctlUpload" /></td>
        </tr>
            
        <tr>
        <td valign="top" style="padding-top: 5px" >Flashcard&nbsp;Text</td>
        <td colspan="2"><textarea name="ctlFlashcardText" rows="2" cols="20" id="ctlFlashcardText" style="height:280px;width:100%;"></textarea></td>
        </tr>
    </table>

If someone kindly could jump in showing how to address just one of the input fields and how to "click" the "upload flashcards" button, I should be able to do the rest myself.

TIA, Rudi.

UploadFlashCards.jpg


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

Hello,

 

This code is opening the right web page, but does *NOT* fill the "form elements" as I would expect:

 

#include <ie.au3>

$URL="http://flashcardsdeluxe.com/flashcards/Upload.aspx"
$DeckCode="SpanischDeck01Basic"
$Deckname="Spanisch Deck01, Grundwortschatz"



$NameDeckCode="ctlDeckCode"
$NameDeckName="ctlDeckName"
$NameFCText="ctlFlashcardText"





$oFCUP=_IECreate($Url,0,1,1,1)
$FormElementDeckCode=_IEFormElementGetObjByName($oFCUP,$NameDeckCode)
_IEFormElementSetValue($FormElementDeckCode,$DeckCode)

$FormElementDeckName=_IEFormElementGetObjByName($oFCUP,$NameDeckName)
_IEFormElementSetValue($FormElementDeckName,$Deckname)

I've installed Autoit v3.3.14.2 and the latest Beta, to try to use IE_Builder2.0.1 (IE-library_v2.0.1.exe) -- hm. Looks like a really huge tool, but I'm too stupid to use it. :-//

 

Regards. Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

Well, I'm pretty new to autoit, but you could try it like that : 

I think the problem with your code is, that you don't declare the form you want to fill. 

<form name="form1" method="post" action="Upload.aspx" id="form1">

This is the form, taken from the html of your homepage

 

Now you can try it like this (didn't test it) : 

 


 

$URL="http://flashcardsdeluxe.com/flashcards/Upload.aspx"

$DeckCode="SpanischDeck01Basic"

$Deckname="Spanisch Deck01, Grundwortschatz" 

$NameDeckCode="ctlDeckCode" 

$NameDeckName="ctlDeckName"

$NameFCText="ctlFlashcardText"





Do
    $oIE = _IECreate($Url,0,1,1,1)
Until IsObj($oIE)



   $oForm = _IEGetObjById($oIE, "form1")       ;you need this to declare the form you want to fill. the form ID is form1 as you can see in the html code


    $oCode = _IEFormElementGetObjByName($oForm, $NameDeckCode) 
    _IEFormElementSetValue($oCode, $DeckCode) 



    $oName = _IEFormElementGetObjByName($oForm, $NameDeckName) 
    _IEFormElementSetValue($oName, $Deckname) 

 

The problem with your code is here : 

 

$FormElementDeckCode=_IEFormElementGetObjByName($oFCUP,$NameDeckCode)

because you directly adress the IE instead of the form. 

 

I hope I could help. 

Share this post


Link to post
Share on other sites

Here a short (tested and working) example on how also click the button : 

 

#include <ie.au3>


;Declare Variables=============================================

$URL="http://flashcardsdeluxe.com/flashcards/Upload.aspx"

$DeckCode="SpanischDeck01Basic"

$Deckname="Spanisch Deck01, Grundwortschatz"

$NameDeckCode="ctlDeckCode"

$NameDeckName="ctlDeckName"

$NameFCText="ctlFlashcardText"

$FcText = "You can use a InputBox or GUI to fill this text"

;===============================================================




Do
    $oIE = _IECreate($Url,0,1,1,1)
Until IsObj($oIE)


_Fill_Name_Code() ;We call the Func


Func _Fill_Name_Code()

   $oForm = _IEGetObjById($oIE, "form1")       ;you need this to declare the form you want to fill. the form ID is form1 as you can see in the html code


    $oCode = _IEFormElementGetObjByName($oForm, $NameDeckCode)
    _IEFormElementSetValue($oCode, $DeckCode)



    $oName = _IEFormElementGetObjByName($oForm, $NameDeckName)
    _IEFormElementSetValue($oName, $Deckname)

    _Fill_Flashcard_Text()

EndFunc



Func _Fill_Flashcard_Text()

    $oForm = _IEGetObjById($oIE, "form1")

    $oText = _IEFormElementGetObjByName($oForm, $NameFCText)
    _IEFormElementSetValue($oText, $FcText)



    _Click_Upload()



EndFunc



Func _Click_Upload()

$oButtons = _IETagnameGetCollection($oIE, "input")
For $oButton in $oButtons
    If String($oButton.value) = "Upload Flashcards" Then
        _IEAction($oButton, "click")
        ExitLoop
    EndIf
Next

EndFunc

 

Share this post


Link to post
Share on other sites

Hi.

Thanks for your replies.

At a glance I didn't get everything, but I'm sure you've pointed me the right direction :D:D

On my way to get familiar with IE.AU3 ...

 

Regards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

Let's say it like that :

 

Each website has it's forms in which the inputs etc. are. 

 

You've created an instance of IE with following code 

$oFCUP=_IECreate($Url,0,1,1,1)

And then you tried to fill the input for the Deck Code with this :

$FormElementDeckCode=_IEFormElementGetObjByName($oFCUP,$NameDeckCode)
_IEFormElementSetValue($FormElementDeckCode,$DeckCode)

You use the code _IEFormElementGetObjByName, so you want to get an FORM element. But you didn't declare the form, you tried to get the Form element straight out of the IE (as you can see at the first parameter, you used the variable for your IE instance there).

 

That's why it didn't work.

 

If you take a deeper look into my code you'll understand it

 

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  

  • Similar Content

    • By ThePoro
      Hi everyone.
      I want to ask about this : 
      I want it runs from 1 to 100 and It opens 10 firefox profiles then access youtube. After I close a firefox window, the loop runs and wait for another window close until loop ends
      I have a loop like this.
      Func launch() Local $from = Int(GUICtrlRead($input1)) Local $to = Int(GUICtrlRead($input2)) If $to <> "" Then While $from <= $to Local $profile = $to _RunDos("start firefox.exe -p " & $profile & " -no-remote youtube.com") $to=$to+1 WEnd Else Local $profile = $to _RunDos("start firefox.exe -p " & $profile & " -no-remote youtube.com") EndIf EndFunc Is there any solution?
      Thank you!
    • By UGH
      Autoit team are assbags.    They want to hold out that they are soooo much smarter than everyone else and they really don't want to help anyone with their questions.   In that case then why have a website.   Oh i know, they get their kicks out of laughing at everyone. 
       
       
       
       
       
       
       
    • By Jemboy
      Hi,
      At work we have some proprietary website, users have to login to.
      I have "made" an autoit executable to start IE, go the website, login, so the user do not have input their credentials every time.
      By NDA I am not allowed disclosed the URL of the website nor the login credentials
      So I made a fake website and an autoitscript to illustrate my question.
      #include <ie.au3> $oIE = _IECreate ("about:blank", 0, 1, 1, 1) $HWND = _IEPropertyGet($oIE, "hwnd") WinActivate ($HWND,"") WinSetState($HWND, "", @SW_MAXIMIZE) _IENavigate ($oIE, "http://demo.rkilinc.nl",1) The above start my demo website. The actual website has some links in the footer that I do not want most people click on.
      I contacted the developers of the website and they are thinking of making an option to configure what links to show in the footer, but they said it's not a high priority for them.
       
      I discovered, that by click F12 and deleting the <footer> element the footer is delete from the live page view (until the page is reloaded off course)
      I want to automate the removal of the footer, without using things like send().
      I tried getting the footer with _IEGetObjById and deleting it with _IEAction, but that didn't work.
      Does any one has an idea how I could delete the footer directly from view with an autoit script?
      TIA, Jem.
       
       

    • By nooneclose
      I want to check some Excel data against data on a website in Chrome. I use Chrome because the site I use does not function properly in Internet Explorer or Firefox. I know how to do the Excel stuff I just can not figure out how to send to Chrome, let alone check to see if the data matches or not. I am also having trouble finding any help online while searching for Chrome functions for Autoit. I have a Chrome UDF installed but I still can not figure out how to get my code to properly function. (I am not posting code because I am  sure my code isn't right, to begin with)
      As usual, any and all help would be greatly appreciated. 
    • By nooneclose
      my FF.au3 does get included but my script does not open firefox. 
      here is my code so far:
      #include <FF.au3> _FFStart("https://www.google.com", Default, 0) I am using firefox portable version 52.0 Any and all help would be greatly appreciated.  
      The code runs but nothing happens. I think the FF.au3 cannot find or connect to the firefox portable.  
×
×
  • Create New...