Jump to content
Sign in to follow this  
rudi

Basic help for filling upload form in browser

Recommended Posts

rudi

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
rudi

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
MorganaFreeman

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
MorganaFreeman

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
rudi
Posted (edited)

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
MorganaFreeman

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
rudi

Yes, thanks.

I read your code several times, I think I got how it has to be done.

 

Have a nice day and thanks again :bye:


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

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

    • TLAM
      By TLAM
      Hello,
      I am working on an autoIT script for CyberArk which is running Internet Explorer and connecting the user to a web application.
      For an unknown reason (I cannot explain why), IE has some trouble to start, only after a long disconnecting period (morning or after lunch). If he tries again, no problem, IE starts.
      I open a case with CyberArk but I am also searching a workaround, I thought to kill the process directly, or set a timeout with _IELoadWait but the process is not really created..

      May do you have any ideas for helping me ?

      Thanks in advance
       
    • Seminko
      By Seminko
      Wrote a script that grabs all of the IP addresses from Netflix's IP log, checks the IPs and returns suspicious activity.
      Everything works as it should but only when _IECreate is set to visible. When visible is set to false, it fails to login for some reason.
      Any ideas what might cause it and/or how to circumvent that?
    • nooneclose
      By nooneclose
      Hello again, I am in phase two of my help bot. I cannot figure out how to properly code Autoit to click on a webpage button using the I.E UDF. I want to click on the button that I have attached as an image. This button does not have a name but it has an ID. Here is the HTML code for this button that I found using chromes developer inspector.
      HTML Code: 
      <img role="button" tabindex="-1" id="toolactions_INSERT-tbb_image" src="nav_icon_insertkey.gif" alt="New Work Order CTRL+ALT+I" draggable="false"> Here is the code that I have so far:
      ;******************************************************************************* ; Opens IE and fill out a New Workorder ;******************************************************************************* ; Start IE at the ** Tracking Application in ****** $oIE = _IECreate("https:I_am_Bound_by_my_company_to_not_reveal_this_webpage") ; Wait for a browser page load to complete _IELoadWait($oIE) Sleep(6000) ; Store the field names where the important data will be sent Local $nWorkOrderB = _IEGetObjById($oIE, "toolactions_INSERT-tbb_image") _IEAction($nWorkOrderB, "click")  I want my program to click on the button that looks like a piece of paper with a blue # 
      (For those wondering, I am allowed to send images just not the URL.) 
      As always any help would be appreciated. 

    • stafe
      By stafe
      Hello
      I am trying to get chrome to save it's current webpage to a pdf using autoit.  I wold like to save the file into a folder on the desktop called "ChromeFiles" .  However when I use the send command chrome only occasionally responds.
      Thank you
      Simon
       
    • nooneclose
      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. 
×