Sign in to follow this  
Followers 0
timmalos

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

7 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Any idea?

Edited by timmalos

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Would it be possible to get the HTML source every second or so and search the source (string) for whatever dynamic elements are available?

Share this post


Link to post
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.

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  
Followers 0

  • Similar Content

    • Spask
      By Spask
      Hi, I'm trying to find a text value inside of a html.
      This is what the line looks like normally:
      <p id="line1" class> <span class="bot">TEXT HERE</span> </p> The text then changes to a non breaking space:
      <p id="line1" class> <span class="bot">&nbsp;</span> </p> And then it changes back to normal text but it's different every time.
      Can I code this so that it grabs the text every time it changes and has a variable that represents it?
      I currently have this inside of my loop:
      $span = .document.getElementsByTagName("span") For $text In $span If $text.value = "&nbsp;" Then Sleep(50) MsgBox(0,0,0) ;messagebox to test if it can be found, but I don't know how to grab the text EndIf Next The problem is that there are many other lines in the html that have the same span but are called "line3", "line5", etc and the one I need is from "line1".
      I will appreciate if anyone can help with this!
    • electrons
      By electrons
      hi  , hope  you all doing well 
       cant find any elements on the page ?  and the right click mouse dont work too?
      iam trying with more than method , i need help please!!
       

    • ur
      By ur
      I have kept below line to wait for IE to load the site completely and continue.
      _IELoadWait($oIE)
       
      But, the code is continuing without waiting for it and I my execution is failing as the elements are not loaded completely.

       
      Any suggestions for alternate code to wait for the browser to load completely?
       
    • ur
      By ur
      We can select elements in IE using their IDs as below.
      Local $oDiv = _IEGetObjById($oIE, "x-auto-16-input") But to one button in the webpage, there is no ID to it.
      In selenium we have option to select this element using the CssSelector and clicked the button using below code in c# selenium.
      driver.FindElement(By.CssSelector("button.x-btn-text")).Click(); What is the alternative for this in AUtoIT?