Jump to content

Problems Clicking <input type="image"


ait
 Share

Recommended Posts

Could somebody help with me this problem?

I am trying to automate filling in a form and submitting the details. I have filled in the details but the submit button is an image

<p><input type="image" src="images/buttons/medium/btn_Submit_0.gif" class="rollover" alt="submit"/></p>

In my script I am trying this:

_IEFormImageClick($formName, "submit", "alt")

$formName is the form name I have also tried this using the url of the page but the image is never clicked (or if it is it's not doing the post action of the form)

If I output the code to a message box it is returning -1

I have also tried using src instead of alt but that isn't working for me either.

Link to comment
Share on other sites

what is the url of the page and can we see your code? Thanks

The URL is internal to work and always different depending on what report I want to download. I know the url is correct as I fill in parts of the form before clicking submit. Here is the function, what it should do is enter a starting from and ending on date and click the submit image to generate a report based on the two dates. It is correctly entering the start and end dates but then it's just closing the page.

Func DownloadReportPage($url)

$startDate = @MDAY - 3 & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN ;; The start date to use - Current date - 3 days
$endDate = @MDAY + 3 & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN ;; The start date to use - Current date - 3 days
    
$oReportPage = _IECreate($url) ;; Open the reports page for the current report

_IELoadWait($oReportPage, 500) ;Wait for the page to finish loading.

$submitReport = _IEGetObjById($oReportPage, "submitReport") ;; submitReport is the form name

$startingOn = _IEFormElementGetObjByName($submitReport, "startDateParam") ;Find the param startdataparam in the form

_IEFormElementSetValue($startingOn, $startDate) ;Set the start date to current date - 3 days

$endingOn = _IEFormElementGetObjByName($submitReport, "endDateParam") ;Find the param endDateParam in the form

_IEFormElementSetValue($endingOn, $endDate) ;Set the end date to current date + 3 days

;;;;;;;;;;;;;;Click submit and get the report;;;;;;;;;;;;;;
sleep(3000)

_IEFormImageClick($submitReport, "submit", "alt") ;; click the form image this is different to clicking an image

_IEQuit($oReportPage) ;; report page opens in a new page so close this one behind me

EndFunc

This is the form with the submit button - I have taken out the data just in case there is any sensitive data in there. Everything I removed was inside a table apart from the data I have left.

<form name="submitReport" method="post" action="JasperReportGenerate.ice" target="_new" onsubmit="window.location.href='JasperReportList.ice'">

<input type="hidden" value="true" name="withParameters"/>

<p><input type="image" src="images/buttons/medium/btn_Submit_0.gif" class="rollover" alt="submit"/></p>

</form>
Edited by ait
Link to comment
Share on other sites

Have you tried this?

_IEFormImageClick($oIE, "submit", "alt")

Yes I tried that and it did the same, although I have just added a 10 second wait after trying to click the submit button and noticed that it goes to a different page, it does this if I pass in $oIE or the form name . If I remove the IEFormImageClick it doesn't do this.

Is there any other code I can post that would help as this is pretty annoying this is the last step in the script :ranting:

Link to comment
Share on other sites

Ok I added the following code to the function get the images on the page and check I was looking at the right url

Local $pp = Int(0)
Local $file = FileOpen("findImageSRC.txt", 1)
FileWrite($file, "Looking for images on " & $url & @CRLF)
Local $oImgs = _IEImgGetCollection($oReportPage)
For $oImg In $oImgs
   $pp = $pp + 1
   FileWrite($file, "Img Info" & "src=" & $oImg.src & @CRLF)
Next

Now I think I am passing something wrong somewhere.

If I do

Local $oImgs = _IEImgGetCollection($oReportPage)
$ooReportPage is
$oReportPage = _IECreate($url)
and $url is what I pass to the DownloadReport function.

The text file created shows I am looking at the correct url and lists all the image apart from two - when I view the source of the page one image is commented out in the source and the other is the submit button image I want to click!

If I do

Local $oImgs = _IEImgGetCollection($url)
- $url is what I pass to the DownloadReport function.

The text file created shows I am looking at the correct url but no images are listed.

Can anyone see anything wrong with the function or know why getting the images of the correct page misses out the one image I need?

Link to comment
Share on other sites

do this help?

$oReportPage = _IECreate($url) ;; Open the reports page for the current report
$submitReport = _IEFormGetObjByName($oReportPage, "submitReport") ;; get submitReport object from its form name
_IEFormSubmit($submitReport);submit it

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

do this help?

$oReportPage = _IECreate($url) ;; Open the reports page for the current report
$submitReport = _IEFormGetObjByName($oReportPage, "submitReport") ;; get submitReport object from its form name
_IEFormSubmit($submitReport);submit it

Thank you!! that's working perfectly!
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...