The script contains the following steps (similar to our ZZ_Google_Driver example script)
Now, with regards to step 3), I understand that we could do the following:
The following VBA code example would wait for ie.document.readyState = "complete" http://stackoverflow.com/a/27137932
Can we do something like that with the Agent Recorder? Or what other way is there to wait until a website A has fully loaded?
Answer by Benjamin W. ·
finding out when the browser has finished loading and has rendered the page is always messy.
You can of course query the readyState as shown in your linked example, but it may not be the answer to all the questions.
I'd probably recommend a combination of the approaches you mentioned in your case, because they can be combined in a single measurement. I wouldn't normally do that, but your use case may be special.
So your transaction could look like this:
WaitForText "Internet Explorer MainWindow", "About"
WaitForText "Internet Explorer MainWindow", "second criteria"
WaitForText "Internet Explorer MainWindow", "third criteria"
This would wait until all the texts have appeared in the browser window. You may find it helpful to place a WaitUntilIEReady in there as well (or your own modified function that waits for the readyState), if it helps as additional criterion (that may vary depending on the website).
I would probably avoid using WaitForImage unless it's absolutely necessary.
Please also keep in mind that checking for more criteria will add additional overhead on the measurement, which may be undesirable. In my experience there is no hard and fast rule, it will depend on what is most important for the customer.
Answer by Yuriy L. ·
I like Benjamin's answer, hopefully what he suggests would satisfy your needs. Just in case, let me give you some more information.
WaitUntilIEReady is intended for waiting until Internet Explorer has finished loading the page. In comparison to the code you reference, it uses a different property of InternetExplorer object – Busy rather than ReadyState and also does not interrogate the root document's and its internal frames' readyState properties.
The approach in the code you reference might for some web pages work better than the Framework's wait functions and Wait method, or could be a good supplementary for them. With that said, please realize that there is no "one size fits all" approach for waiting. Each application is different, many Web pages include scripts, and some Web contents may be downloaded after whatever wait criteria is met. For instance, the sites that report ongoing, say, sports, events, no state is final, so what is "fully loaded"?. Despite this complexity, for the great majority of our customers one of or the combination of the waiting options available in the Recorder and in the Framework does what they need.
If, nevertheless, you need to try the approach from the code you reference, converting VBS into VBA should be easy. Sometimes the code would word as is, sometimes you may need to modify Dim statements to include variables types, possibly you may also need to declare some variables because in VBA we use "Option Explicit".
Should you need more specific help, please open a support case.
Answer by Tomislav F. ·
Thanks a lot for the answers! One last question around that topic:
Lets assume we have a simple script as described above:
In this script we are just having one transaction => how long does it take to load website A
Now, if we had an URL autocheck for website A, would there be any difference? Please disregard the difference in terms of setting up and configuring an URL autocheck vs an active script, this question is targeting the result (transaction time - how long does it take to fully load website A).
Our documentation here states:
This Automated Check also reports the time it takes for a page to load
In short, is there any difference between an URL autocheck and a simple active script that measures how long it takes to load an URL?
Answer by Tomislav F. ·
Thanks a lot for the detailed answers! As recommended, we will try to work with a combination of WaitForText (or IEWaitForText) followed by WaitUntilIEReady.
I am experimenting in my own environment in order to implement the following example: http://stackoverflow.com/a/27137932
I cannot implement it in the actual script itself as the "InternetExplorer" object is not recognized there when I run the script
Dim objIE as InternetExplorer Error message => User-defined type not defined
Hence, I have created a custom method WaitUntilIEReadyCustom in CVFW_Wait_Utilities. The InternetExplorer object is recognized there. I am then calling WaitUntilIEReadyCustom from my "Hello World" script. The following part seems to work:
'Step 1 => Wait for page to connect 'WORKS ShowStatusBox "Test - Waiting for IE to be ready", True Do Until objIE.ReadyState = 4 Sleep 200, tpPauseMilliSeconds Loop
I am stuck at the following part, which seems to not work yet (objIE.Document.ReadyState seems to not work). I am not sure if I can invoke "ReadyState" directly on the Document property. I have checked the documentation here
'Step 2 => Wait for document to load 'Does not work yet => Document.ReadyState ? ShowStatusBox "Test - Waiting for DOCUMENT to be ready TF", True Do Until objIE.Document.ReadyState = "complete" Sleep 200, tpPauseMilliSeconds Loop
Any thoughts of how we can translate the "wait for document to load" part?