Jump to content
Sign in to follow this  
eibbtoddb

Javascript button submit?

Recommended Posts

I am trying to automate the "clicking" of a button (or link) on a website.  I am very new to AutoIt and am not sure how to get this done.  

When I hover over what looks like a hyperlink, I see this message, "javascript:void(0);"  When I view the page source, I see this code:

function HandleSubmit(astrValue)
    {  
       document.getElementById('HiddenFormSubmitted').value = astrValue;
       document.getElementById('PageForm').submit();
       if (astrValue != 'DOWNLOADREPORT' && astrValue != 'DOWNLOADREPORTEXTENDED') {
           DisableFields();
       }
    }
 
I also found this href in the page source:
 
<a href="javascript:void(0);" onclick="HandleSubmit('DOWNLOADREPORTEXTENDED');return false;" target="_blank" class="UPE-Link"><img src="/shared/assets/legacy/affiliatesweb/engine/images/download.gif" border="0" style="vertical-align:text-top;" /> Download Extended Report</a>             
 
I need to submit/click the button/link that submits the 'DOWNLOADREPORTEXTENDED' portion.  When I click it on the website, a .csv file is downloaded to to my computer.  This is what I need to automate on a daily basis.
 
Thanks in advance for your help!
~Todd

Share this post


Link to post
Share on other sites

Thanks for the reply!  Yes, IE for now.    Is there any other code I need other than that single line?  This is only my 2nd day using AutoIT and I'm not too familiar with all the available functionality.

So far, I really like this tool!

Share this post


Link to post
Share on other sites

You could look up IE functions in the help file, the help file is the best place for you to start. You could also open the includes folder where you installed AutoIt and then check IE.au3 to learn about its functions and how they work.

Share this post


Link to post
Share on other sites
This is what I have so far....
 
#include <IE.au3>
 
 
$UserName = _IEGetObjByName($oIE, "txtUsername")
$Password = _IEGetObjByName($oIE, "txtPassword")
$BtnLogin = _IEGetObjByName($oIE, "btnLogin")
$BtnSearch = _IEGetObjByName($oIE, "cmdSearch")
 
_IEPropertySet($UserName, 'innerText', 'mysusername')
_IEPropertySet($Password, 'innerText', 'mypassword')
 
_IEAction ($BtnLogin, "click")
 
_IELoadWait($oIE)
 
 
_IELoadWait($oIE)
 
_IEAction ($BtnSearch, "click")
 
_IELoadWait($oIE)
 
$oIE.document.parentwindow.execScript("HandleSubmit('DOWNLOADREPORTEXTENDED');")

Share this post


Link to post
Share on other sites

$BtnSearch = _IEGetObjByName($oIE, "cmdSearch")
--> IE.au3 T3.0-1 Warning from function _IEGetObjByName, $_IESTATUS_NoMatch (Name: cmdSearch, Index: 0)

Try this:

#AutoIt3Wrapper_Run_Debug_Mode=y
#include <IE.au3>
$oIE = _IECreate("https://affiliates.upickem.net/net/Welcome.aspx")
$UserName = _IEGetObjByName($oIE, "txtUsername")
$Password = _IEGetObjByName($oIE, "txtPassword")
$BtnLogin = _IEGetObjByName($oIE, "btnLogin")
_IEPropertySet($UserName, 'innerText', 'mysusername')
_IEPropertySet($Password, 'innerText', 'mypassword')
_IEAction ($BtnLogin, "click")
_IELoadWait($oIE)
$oIE = _IENavigate($oIE, "https://affiliates.upickem.net/Engine/ProfitReport.aspx?contestid=12345")
_IELoadWait($oIE)
$BtnSearch = _IEGetObjByName($oIE, "cmdSearch")
_IEAction ($BtnSearch, "click")
_IELoadWait($oIE)
$oIE.document.parentwindow.execScript("HandleSubmit('DOWNLOADREPORTEXTENDED');")
Edited by Exit

UDF: _SingleScript()                                        If you like my post, just click the like button :)        here -->

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  

×
×
  • Create New...