browser.busy browser.readystate

Started by RAK, March 21, 2014, 05:03:08 PM

Previous topic - Next topic

RAK

Is it possible to detect when java is running on a page? During automated COM lookups - I pause to wait for the browser to complete procedures. The normal routines seem to be blind to java functions run by the page. I have added fixed delays on top of delays based on .busy  and .readystate status. The delays must be longer than desired for larger results and/or slower machines.

Before I attempt a 'workaround' - is there any "in process" method for java? 

I have noticed that .readystate returns 4 and 'complete' - are there any other values that may help? What does the .readystate=4 mean? maybe that's it?

Here is what I am using:
While browser.busy || browser.readystate == 1
and
While browser.Document.ReadyState != "complete"

Maybe another option?

thanks

I just got his and after testing .readystate returns 4 while java is running

READYSTATE_UNINITIALIZED (0)

The object has been created, but not initialized (the open method has not been called).

READYSTATE_LOADING (1)

A request has been opened, but the send method has not been called.

READYSTATE_LOADED (2)

The send method has been called. No data is available yet.

READYSTATE_INTERACTIVE (3)

Some data has been received; however, responseText is not available.

READYSTATE_COMPLETE (4)

All the data has been received.

I have tested with browser.readystate and browser.document.readystate but they return '4' and 'complete' respectively - before data is acquired.

RAK

I have a solution that looks for an HTML tag that disappears while the java is running. When it re-appears - then I go.. This is working well but if there is a way to see if java is running - I would rather use it.
Here it is in case anyone has a use for it

   done = 0
   while 1
      as = browser.Document.GetElementsByTagName("a")
      ForEach a in as
         if a.id == 'IdOfItemThatAppearsAfterJavaIsDone'
            done = 1
            break
         endif
      next
      if done then break
      else timedelay (2)
   endwhile
   timedelay (2)

thanks

stanl

Quote from: RAK on March 21, 2014, 05:03:08 PM
Here is what I am using:
While browser.busy || browser.readystate == 1
and
While browser.Document.ReadyState != "complete"


I had a similar issue with a TOA website that uses JQuery and hidden DIVs.  It appears the .readystate can be on and off until the browser is actually ready.

I only used
While browser.busy

With loops and timeouts... pretty ugly kludge but it did the job.


RAK

Thanks for the reply

browser.busy returns 1 or 0 correct?
   While browser.busy
      TimeDelay(1)
   EndWhile


If so, browser.busy is not detecting java. Returns while java is still running. This is becoming more of an issue (at least for me) as java is everywhere on the sites I am working on. (jQuery)

It seems to treat java the same way as it returns browser status to these functions. If you click a link on the page while java is running - it kills the java process and follows the clicked link. As though it's not busy.




Deana

As I understand it there are no IE methods to determine a javascript is running or has completed. You will need to add code to your script to check for the element to appear that is generated by the script.
Deana F.
Technical Support
Wilson WindowWare Inc.

JTaylor

"I feel your pain" :)

Working on a project today with that problem.  I ended up doing something like the following.  I did the navigate again with an increased delay as I wasn't sure if the GetElements would pick up the changes from the JQuery response if they weren't there on the first check.

Jim

Code (winbatch) Select

  xtxt = ""
  cnt = 1
  While 1
    xlst = ybrowser.document.GetElementsByTagName("body")
    ForEach i In xlst
      xtxt  = i.OuterHTML
      i_rows = udfGetElementsByClass(i, "DIV", "resourceContent")
    Next
    If i_rows[0] > 0 || StrIndexNC(xtxt,"No rows found",0,@FWDSCAN) > 0 Then Break
    cnt = cnt + 1
    ybrowser.navigate(URL)
    TimeDelay(cnt)
    WaitForBrowser2(yBrowser)
  EndWhile

RAK

looks like our similar solutions; looking for Jquery result content, is the way to go (the only way).
Thanks

stanl

Quote from: JTaylor on March 26, 2014, 03:46:52 PM
"I wasn't sure if the GetElements would pick up the changes from the JQuery response if they weren't there on

Pretty much like I mentioned... where you used While 1, I used While browser.busy... At one point I investigated the JQuery Object in IE, then using Ajax to get the data from a hidden DIV, i.e.

If oIE.document.ready(function())  where function() can be set to retrieve the desired information. Now I wonder if System.Web.Script.Services and the CLR can be of any help?

...Sunday rambling....

RAK

I took for granted that new elements would been seen. What I have seen is that jquery writes the resulting 'new' html to the page that COM sees when it completes. All new content added by each and every jquery remains in the HTML even if it cannot be seen by a user - COM sees it. Until the page is refreshed/navigated. Even the original search form/input fields that disappear after the initial jquery search are still in the HTML after the search results are in view. It seems jquery does not remove any "old' html - (makes sense), it adds new html and controls what the user sees.

I have been using a loop similar to the one I posted and so far has been initiated about 20k times in testing - never failing. It delays processing sometimes up to 20 seconds as required.. Cool..

thanks

JTaylor

Appreciate the info.  I may go back and remove the subsequent navigate.

Jim