ToUrl method opens the page specified by the URL parameter in the web browser and returns the
Page program object that corresponds to the new page. You can use the
Exists property to determine if the new page was loaded successfully.
|TestObj||A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section|
|WaitTime||[in]||Optional||Integer||Default value: -1|
The method is applied to the following object:
The method has the following parameters:
The URL to navigate to. It is recommended to specify the protocol in the URL. Otherwise, the page might not be loaded. For example, use http://www.smartbear.com rather than www.smartbear.com
If the tested web page is located on your computer, then to make your script computer-independent, use the server name rather than localhost when specifying the page’s URL, that is, for instance, use the URL http://mycomp/path/mypage.htm rather than http://localhost/path/mypage.htm. See Computer-Specific Settings for more information about this.
Specifies the time (in milliseconds) to wait until the browser loads the page and becomes ready to accept user input. If WaitTime is omitted, the timeout is specified by the project's Web page loading timeout option. After the specified time limit is reached, the test execution proceeds.
Page object that represents the new web page.
To determine whether the specified web page has loaded completely, TestComplete uses the following techniques:
contentDocument.readyStateproperty of the loaded HTML document.
WebViewClient.onPageFinished()native methods of the Android application.
The described mechanism of determining whether a web page has been downloaded completely is acceptable only for static web pages and is not effective for pages with dynamic content. For more information, see Waiting For Web Pages and Waiting for Web Pages in Hybrid Mobile Applications.
ToURL method uses two waiting periods:
First, the method waits for the web page to load for the timeout period specified by the WaitTime parameter and stops waiting when it determines that the page has been loaded completely or after the timeout elapses.
The method also stops waiting if the loaded page displays a login dialog. In this case, you need to create test commands that simulate user actions over the dialog to closes it.
After the method stops waiting for the page to be loaded, it waits for the time specified by the Auto-wait timeout setting until the object hierarchy contains the desired
When recording actions that open a web page, TestComplete automatically transforms them into the appropriate calls of the
ToUrl method. However, a method call is not inserted into the test, unless some other actions (mouse clicks, keyboard input, checkpoints, etc.) are performed over the opened page.
ToURL automatically sets the zoom ratio of the destination page to 100%.
If User Account Control (UAC) is enabled on your computer, the
Page object corresponding to the current web page opened in Internet Explorer is destroyed if the
ToURL method navigates to a page that belongs to another domain. Then, a new
Page object that corresponds to a target page in Internet Explorer is created. If you face any issues caused by this behavior, you can do the following:
Page object that corresponds to the desired web page.
Run TestComplete with administrator privileges. For information on how to do this, see Using TestComplete With Administrator Privileges.
The following example opens a new page and checks whether it has loaded successfully.
var NewPage = Page.ToUrl("www.MyURL.com");
if (! NewPage.Exists)
NewPage = Page.ToUrl("www.MyURL.com") if not NewPage.Exists: # Error! Log.Error("Texty text.")
Set NewPage = Page.ToUrl("www.MyURL.com")
If Not NewPage.Exists Then
NewPage := Page.ToUrl('www.MyURL.com');
if not NewPage.Exists then
var NewPage = Page["ToUrl"]("www.MyURL.com");
if (! NewPage["Exists"])