NavigateTo Method (Page Objects)

Applies to TestComplete 15.63, last modified on April 23, 2024
This method is obsolete. See the Remarks section below.

Description

The NavigateTo method lets you open the page specified by the URL parameter in a web browser. The NavigateTo method waits until the specified web page is opened. It is similar to the ToUrl method, but does not return any value. If you call NavigateTo, you will have to obtain the Page object corresponding to the loaded page. For more information on this, see Navigate to Web Pages.

Declaration

TestObj.NavigateTo(URL, WaitTime)

TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
URL [in]    Required    String    
WaitTime [in]    Optional    Integer Default value: -1   
Result None

Applies To

The method is applied to the following object:

View Mode

To view this method in the Object Browser panel and in other panels and dialogs, activate the Advanced view mode.

Parameters

The method has the following parameters:

URL

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.example.com rather than www.example.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.

WaitTime

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.

Result Value

None.

Remarks

  • This method is obsolete. To open the page specified by the URL parameter in a web browser, use the ToUrl method.

  • If the method navigates to a web page successfully, it posts an event message to the test log.

  • If the method cannot navigate to a web page, it fails and posts an error message to the test log.

  • To determine whether the page has been loaded, the NavigateTo method checks the contentDocument.readyState property of the loaded HTML document for the time specified by the WaitTime parameter. The method exits when the property reports that the loading is complete or when the timeout elapses.

    The method also exits if the loaded web page displays a login dialog. This allows your tests to simulate user actions and to close the dialog.

    This mechanism of determining whether a web page has been completely downloaded is acceptable only for static web pages and is not effective for pages with dynamic content. For more information, see Wait For Web Pages.

  • NavigateTo automatically sets the zoom ratio of the destination page to 100%.

Example

The following example demonstrates how to navigate to a web page:

JavaScript, JScript

function NavigateToSample()
{

  Browsers.Item(btIExplorer).Run("about:blank");
  var page = Sys.Browser().Page("about:blank");

  …

  // Navigate to the web page
  page.NavigateTo("http://smartbear.com");

  …

}

Python

def NavigateToSample():
  Browsers.Item[btIExplorer].Run("about:blank")
  page = Sys.Browser().Page("about:blank")

  # ...

  # Navigate to the web page
  page.NavigateTo("http://smartbear.com")

  # ...

VBScript

Sub NavigateToSample

  Browsers.Item(btIExplorer).Run("about:blank")
  Set page = Sys.Browser.Page("about:blank")

  …

  ' Navigate to the web page
  page.NavigateTo("http://smartbear.com")

  …

End Sub

DelphiScript

procedure NavigateToSample();
var page;
begin

  Browsers.Item(btIExplorer).Run('about:blank');
  page := Sys.Browser.Page('about:blank');

  …

  // Navigate to the web page
  Page.NavigateTo('smartbear.com');

  …

end;

C++Script, C#Script

function NavigateToSample()
{

  Browsers["Item"](btIExplorer)["Run"]("about:blank");
  var page = Sys["Browser"]()["Page"]("about:blank");

  …

  // Navigate to the web page
  page["NavigateTo"]("http://smartbear.com");

  …

}

See Also

Classic Web Testing
ToUrl Method (Page Objects)
URL Property (Page Objects)
Wait Method (Page Objects)
Navigate to Web Pages

Highlight search results