Jump to content

IE.au3 and Javascript :Wait page AND javascript fully loaded


Recommended Posts

Hi guys.

First of all, i hope u will understand my problem as i'm French and i'm not very good in English.

I got a trouble with my simulation.

I want to create a script that do some actions on a webpage. I use IE.au3, but the page is a full javascript application, so when IE is fully loaded (and _IELoadWait() ends) some content is still created dynamically by Javascript.

Before i can do my job and click on a button with DOM functions, i need to really WAIT javascript's work is finished.

Is there a way to do it?

Thx for ur help,

Tim

Edited by timmalos
Link to comment
Share on other sites

Is there a way to do it?

I doubt it. Here are two things that MIGHT work:

Look around the page and find an element that is dynamically created.

Then, using IE.au3, continuously poll for data about this element. When it succeeds/gives-empty data, you know the page exists and the Javascript is loaded, as Javascript created that element in the first place.

Option 2:

Use a hard coded timer or user input. This may work depending on the complexity of the javascript, operating environment etc.

ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

Link to comment
Share on other sites

I currently use your option 2 with sleeps, but i want to do better as i need to make a general solution (because i generate these simulations automatically and don't know how many sleeps i need to put in seach simulation).

Furthermore, i need to get the exact time the simulation takes (monitoring/supervision task) and with sleeps i can't have a good timer.

Your option 1 would be great but like in my first sentence i must do as if i didn't know the relevant page. Hence i can't say ok i wait for THIS element to be load. But maybe is it possible to add myself an element at the end of the page with Javascript and wait for him to answer? I don't think so cause he will be inserted by another Javascript thread regardless to the javascript running by IE, but maybe someone can have an idea.

Edited by timmalos
Link to comment
Share on other sites

So you know enough about the pages to be able to manipulate them after they are loaded, but not enough to know what dynamic elements you can look for on the page? This sounds strange - perhaps you need to explain in more detail.

There is no general answer to your question. The Ajax processing is asyncronous and there is no way for the browser to know whether it is complete or not. You'll need to apply your knowledge about the pages to devise a scheme that works for you.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

So you know enough about the pages to be able to manipulate them after they are loaded, but not enough to know what dynamic elements you can look for on the page? This sounds strange - perhaps you need to explain in more detail.

I mean i can manipulate the page after she is loaded because my scenario does it. But This scenario is generated by a robot. The human (who don't know anything about Autoit) say : I want to do this and this on this page.So my scenario does these actions after the page is loaded.That could work if i asked my user to say to my robot : "The last element loading is ..." but generally he won't be able because he dosn't know anything in development.

That's why i asked a 'general solution' so that my robot wait with _IeLoadWait and do some actions to verify the page is well loaded and then do what the user asked.

But it seems impossible so i'll open a support for each scenario : If there is a problem i'll correct the scenaio manually myself.

Edit : Or something i could do using GMK idea is : The first time scenario is launch, he wait some time with Sleep() for example, each second he get the DOM source and see which element is the last (or at least in the lasts), write it and then use this element next.

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