Jump to content

How to click a link/button in a HTML5 container?


Dent
 Share

Recommended Posts

As the title says. I open IE11 and navigate to a page with the following HTML5 file upload container in Capture0.JPG

I want to click Add Files but I haven't been able to. Here's the code that handles the Add Files button in Capture.JPG

_IEGetObjectById and then using _IEAction to click it doesn't work. I can't give access to the actual page unfortunately because it's password protected.

All suggestions welcome.

Capture0.JPG

Capture.JPG

Link to comment
Share on other sites

  • 2 months later...

I'm hoping to resurrect this thread now that I can link directly to the page that I'm trying to interact with.

Here is the page http://mmmortgages.co.uk/axsdb/upload.php

I would like to be able to upload a file using AutoIt. My current solution involves moving the mouse pointer to certain coordinates and sending a left mouse button click. It works but it's crude and I would like a solution that can select the two buttons programmatically.

If you're kind enough to try and help me with this, please only upload small files when testing your code.

I understand using jQuerify could provide a solution but I have zero experience with jQuery.

Link to comment
Share on other sites

The button works as I would expect (file dialog box appears after clicking). What exactly isn't working as you would expect?

#include <IE.au3>

$oIE = _IECreate ("http://www.mmmortgages.co.uk/axsdb/upload.php", 1)

$oAddFiles = _IEGetObjById($oIE, "html5_uploader_browse")

; Either of the following worked for me
;$oAddFiles.click()
_IEAction($oAddFiles, "click")

 

Link to comment
Share on other sites

Thanks Danp2. For some reason on my system if I create the IE instance and then navigate to that page it doesn't work, but if I create the IE instance directly at that page it does work.

Link to comment
Share on other sites

Hmm - but now the following code that was working perfectly after using MouseMove MouseClick no longer works

WinWait("Choose File to Upload")
$hChoose = WinGetHandle("Choose File to Upload")
Sleep(1000)
ControlSetText($hChoose, "", "Edit1", "C:\ProgramData\IRESS\TrigoldProspector\Main.DLT")
Sleep(1000)
Send("{ENTER}")
Sleep(1000)

Nothing is written into the File name field of the dialog box. Any idea why?

Link to comment
Share on other sites

It seems the _IEAction($Object, "click") and $Object.click() leave IE hanging and the rest of the code never executes. This would seem like a UDF/AutoIt bug to me.

I'm using version 3.3.14.3

Link to comment
Share on other sites

Thanks Danp2.

For anyone else who stumbles across this thread; certain actions carried out in AutoIt cause the script to hang, meaning the remainder of the script won't execute until whatever is causing the hang is dealt with, usually by user interaction (e.g. clicking 'ok') which defeats the purpose of a script to automate a task.

To overcome this a second script can be called to take care of whatever the first script is waiting for. This is the solution I used and it works 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

×
×
  • Create New...