Ask a Question

ToURL method

kinsleyd
Contributor

ToURL method

I just upgraded from a demo version of TestComplete to the full enterprise version, and have found that the ToURL method no longer seems to wait for the page to load before the script continues to run.  Its pretty vital that I find a way to return to the time when ToURL waits - anything I can do?

Thanks
8 REPLIES 8

RE: ToURL method

Hi Dave,




The ToUrl method calls the Page.Wait method, and there is a difference in this functionality between the Demo and Enterprise versions of TestComplete. Unfortunately, the algorithm used by TestComplete to wait until a page is completely loaded is not ideal as modern web applications are very dynamic and it can be almost impossible to catch the moment when they are loaded. I recommend that you go through the 'Waiting For Page' help topic containing possible solutions for such applications.

--
Dmitry Nikolaev

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
kinsleyd
Contributor

RE: ToURL method

Here's a line from the help file:


  • The ToUrl method belongs to the Page
    object, to window
    objects that contain the Page object and to process
    objects that correspond to Internet Explorer or Firefox. The method is used to
    load a web page in the browser. It automatically “waits” until the specified web
    page is opened.


This method used to work for me.  I have hundreds of lines of script that rely on this method to wait for the page to finish loading.  I do not have time to re write the entirety of my code.  Please advise on how I can get this functionality back.  If I need to some how unlock the demo version so it will not have the restrictions placed on it that would be fine (like the time period and limitations on how much script can be loaded).  I'd be happy to give up the extra features of the enterprise version (like methods no longer working properly).



Thanks

RE: ToURL method

Hi Dave,




The Web Testing feature works absolutely similarly in the Demo and Enterprise editions of the tool. If the behavior has changed, most probably, this is caused by a change in the tested application. Other possible causes are a slower Internet connection or faster computer.




As a workaround, you can increase the value of the 'Auto-wait timeout' option in your project. The default value is 10000 ms, and you can increase it, for example, to 30000 ms. This option is located in the Playback option group of the project properties editor. To open the editor, double-click the project node in the 'Project Explorer' panel and switch to the Properties page.




Can you provide us with access to the tested application so we can reproduce this behavior and find the best way to wait until pages in it are completely loaded?

--
Dmitry Nikolaev

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
kinsleyd
Contributor

RE: ToURL method

David,



Nothing changed with the application or the computer the script is running on, but adjusting the timeout did have an impact.  Perhaps that implies that the default values is different between the demo version and the enterprise?  No telling at this point, but its all good now that my code is working again.  Thanks!



Dave

RE: ToURL method

Hi Dave,




This is a project-specific option and, therefore, different TestComplete's editions should work with it in the same way. Nevertheless, I am glad that this solves the problem you faced.

--
Dmitry Nikolaev

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
kinsleyd
Contributor

RE: ToURL method

I'm still having issues with waiting for a page to load.  I'm trying the page.wait method now, and I'm uncertain of precisely how to extract what it returns.  For instance:


Sub BasicsFA_RegionSum


BasicsFA_RegionSum

Call iexplore.ToURL(Project.Variables.server & "gsa/webbas01.nsf/(vwWebPage)/Webbase.htm?OpenDocument&Set=1,Scope=RS______,App=Basics__________,Select=P-Active,")

 

str = iexplore.Page(Project.Variables.server & "gsa/webbas01.nsf/(vwWebPage)/Webbase.htm?OpenDocument&Set=1,Scope=RS______,App=Basics__________,Select=P-Active,").Wait

 

In the example above, the str variable is indeed getting populated, but with something very different than the URL of the page.  There are frames involved on the pages in question.  I'm uncertain how best to accomplish what I need here.  I was hoping the str variable would return the URL, then I could easily run a compare of it vs. the string of the URL and log the results if they were different, but it seems when set str = iexplore.Page(URL).wait, the .wait bit isn't waiting.  I'm at a loss here.



Any suggestions?  I've tried the technique listed in the help file as follows:


Sub BasicsFA_RegionSum



Dim iexplore


Set iexplore = Aliases.iexplore



 



call iexplore.ToURL(Project.Variables.server & "gsa/webbas01.nsf/(vwWebPage)/webbase.htm?OpenDocument&Login&Set=1,Scope=PS______,App=Basics__________,Select=P-Active,")


Set pg = iexplore.ToURL(Project.Variables.server & "gsa/webbas01.nsf/(vwWebPage)/Webbase.htm?OpenDocument&Set=1,Scope=RSLU____,App=Basics__________,Select=P-Active,")


' Wait for frames

 



waitFrm = True

 



Set Frames = GetFrames(Pg) ' Obtain the frames collection

 



While waitFrm


For Each Frame In Frames


If Frame.Exists Then

 



waitFrm = waitFrm And (Frame.readyStateValue <> 4)


End If

 



Next

 



If waitFrm Then

 



aqUtils.Delay 100


End If

 



WEnd

 



msgbox ("page loaded")



End Sub


' Obtain the frames collection



Function GetFrames(APage)





GetFrames(APage)

Select Case Options.Web.TreeModel


Case "DOM" Set GetFrames = APage.document.frames ' DOM model

 



Case "Tag" Set GetFrames = APage.FRAME ' Tag model

 



Case Else Set GetFrames = APage ' Tree and Hybrid models

 



End Select

End Function

This only results in the script being caught in an infinite loop even after the page finishes loading (which takes something on the order of 30 seconds).



Thanks!




RE: ToURL method

Hi Dave,




Try the following code:




Call iexplore.ToURL(Project.Variables.server & "gsa/webbas01.nsf/(vwWebPage)/Webbase.htm?  OpenDocument&Set=1,Scope=RS______,App=Basics__________,Select=P-Active,")

iexplore.Page(Project.Variables.server & "*").Wait

str = iexplore.Page(Project.Variables.server & "*").LocationURL

--
Dmitry Nikolaev

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
kinsleyd
Contributor

RE: ToURL method

I think I finally got it worked out.  After beating my head against the wall about the readystate property, I finally found that it was returning a value of 4 immediately, even while the page was still loading.  So I dug a little deeper in the Object Browser and found the each one of the main frames had a readystate value, but in this case it was a text string - either "loading" or "completed".  So I isolated the frame in question and used it in the loop that checks for its value, and voila - seems to work:


call iexplore.ToURL(Project.Variables.server & "gsa/webbas01.nsf/(vwWebPage)/Webbase.htm?OpenDocument&Set=1,Scope=RSLU____,App=Basics__________,Select=P-Active,")


iexplore.ToURL(.Variables.server & "gsa/webbas01.nsf/(vwWebPage)/Webbase.htm?OpenDocument&Set=1,Scope=RSLU____,App=Basics__________,Select=P-Active,")

set pg1 = iexplore.Page(Project.Variables.server & "gsa/webbas01.nsf/(vwWebPage)/Webbase.htm?OpenDocument&Set=1,Scope=RSLU____,App=Basics__________,Select=P-Active,").Frame("fraMain")


waitFrm = True


While waitFrm


    msgbox(pg1.readystate)


    waitFrm = waitFrm And (pg1.readyState = "loading")


        If waitFrm Then


            aqUtils.Delay 100


        End If


WEnd


Gotta love that Object Browser!!





cancel
Showing results for 
Search instead for 
Did you mean: