Jump to content

Automating a tricky (html/java) web interface (no API)


Recommended Posts

Hi, I've been tinkering and tinkering and I really hope someone can give me some advice.

I've used the IE.au3 UDF successfully with some different scripts, just I'm not even sure I'm going in the right direction on this one.

A bunch of text input fields on a secure site are to be updated with data in the script (which the script gets from an excel file), and submitted. Not too hard, right?

The input fields html looks like this: (in this case current value is 777.00)

<input id="pt1:r1:1:pt1:ghostText:i10:0:lvl2:0:lvl3:0:lvl3PrcHdr:i15:0:lvl3Prc:ot21::content" name="pt1:r1:1:pt1:ghostText:i10:0:lvl2:0:lvl3:0:lvl3PrcHdr:i15:0:lvl3Prc:ot21" class="x25" type="text" value="777.00" title="777.00">

I've tried

_IEFormElementSetValue($oObj, $sInput, 0)
_IEFormElementSetValue($oObj, $sInput, 1)
$oObj.setAttribute("value", $sInput)
$oObj.setAttribute("title", $sInput)
_IEAction($oObj, "focus")
$oObj.fireEvent("onfocus")

in various combinations and orders, and the trouble is always that some fields are "skipped" or revert back to their previous value a few seconds later.

Even though not actually submitting ie. clicking the "Save Changes" button on the page, some kind of processing is already going when anything is changed/focused etc., as far as I can see.

What else I have tried:

Using ControlSend($g_oIEHandle, "", "[CLASSNN:Internet Explorer_Server8]", $sInput) in combination with a lot of MouseGetCursor() I have a more simple script roughly "working" (doesn't use any IE objects). It works by waiting for a normal mousecursor for the page to be "ready" again in between inputfields... ...and this ends up being very slow and not much faster than human entry, and "only" fails sometimes (which is why there is a checking function as well, though this also adds to the time taken).

 

So what can I do?

From some research I've done, I understand there may be some way to cancel events (I know as much as that events have a propery "cancelable"). Maybe we can stop any javascript function from being called while filling all the input fields somehow, so that none of the input gets lost.Could this help? How to do this?

One other idea is with POST and GET, so that the data that is usually submitted to the site on "Save Changes" can be sent without interface interaction... would this probably be very difficult to attempt? Where to start? (https...)

Please, any thoughts, guidance on the above, or ideas/approaches I haven't thought of?

Edited by guestscripter
Link to comment
Share on other sites

Alright so this gives me more useful info on understanding what's going on in terms of events...

especially this part I didn't know about before;

You can use monitorEvents function.

Just inspect your element (right mouse click → Inspect on visible element or go to Elements tab in Chrome Developer Tools and select wanted element) then go to Console tab and write:

monitorEvents($0)

Now when you move mouse over this element, focus or click it, the name of the fired event will be displayed with its data.

To stop getting this data just write this to console:

unmonitorEvents($0)

$0 is just the last DOM element selected by Chrome Developer Tools. You can pass any other DOM object there (for example result of getElementById or querySelector).

You can also specify event "type" as second parameter to narrow monitored events to some predefined set. For example:

monitorEvents(document.body, 'mouse')

List of this available types is here.

http://stackoverflow.com/questions/10213703/how-do-i-view-events-fired-on-an-element-in-chrome-web-developer

 

Now what I could really use help with is learning how to manipulate/stop/pause these events manually.... any tips much appreciated!

Link to comment
Share on other sites

there is no such thing as tricky webpage. I assume your question is how to fill the form and not about disabling events.

see https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/

and to see if your page is really the problem check what you can do with javascript in your addressbar and if you get same tricky behavior

1. go to www.autoitscript.com/forum

2.type in addressbar:     javascript:document.getElementById("elSearchField").value="IUIAutomation";void(0);

 

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...