Navigate Method

Applies to TestComplete 15.45, last modified on December 01, 2022

Description

Opens a web page with the specified URL in the existing instance of the browser.

Declaration

BrowserInfoObj.Navigate(URL, WaitTime)

BrowserInfoObj An expression, variable or parameter that specifies a reference to a BrowserInfo object
URL [in]    Required    String    
WaitTime [in]    Optional    Integer Default value: -1   
Result None

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

URL

The URL of the web page to be opened.

We recommend that you specify the complete URL of the desired page, including the protocol name, page extension, trailing slash and so on. For instance, https://developer.mozilla.org/en-US/. You can copy the complete URL from the browser’s address bar.

WaitTime

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

  • To improve the Firefox performance, the method automatically configures some Firefox settings before navigating to the specified web page.
    These settings will not be restored to their initial values after the test run is over.

    To prevent TestComplete from modifying your Firefox settings, do not use the Navigate method (and the BrowserInfo.Run method) in your test. As a workaround, you can launch Firefox by using the TestedApp.Run method and navigate to web pages by simulating user actions on the browser's address bar.

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

  • If the browser is not running, the Navigate method fails and posts an error 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.

  • If your test installs or uninstalls browsers during the run, then you need to update the browser collection before continuing the test. To do this, call the Browsers.Refresh method before launching a browser, navigating to a web page or performing any other browser-related operation after the installation or uninstallation is over.

Example

The following code launches a browser, opens the Main page of the SmartBear web site and then calls the Navigate method to open the Products page in the same instance of the browser:

JavaScript, JScript

function Test()
{
  // Launch browser and open the Main page
  Browsers.Item(btIExplorer).Run("http://smartbear.com");
  // Test the Main page
  ...

  // Open the Products page
  Browsers.CurrentBrowser.Navigate("http://smartbear.com/products");
  // Test the Products page
  ...
}

Python

def Test():
  # Launch browser and open the Main page 
  Browsers.Item[btIExplorer].Run("http://smartbear.com");
  # Test the Main page
  # ...

  # Open the Products page 
  Browsers.CurrentBrowser.Navigate("http://smartbear.com/products");
  # Test the Products page
  # ...

VBScript

Sub Test
  ' Launch browser and open the Main page
  Browsers.Item(btIExplorer).Run("http://smartbear.com")
  ' Test the Main page
   ...

  ' Open the Products page
  Browsers.CurrentBrowser.Navigate("http://smartbear.com/products")
  ' Test the Products page
   ...
End Sub

DelphiScript

procedure Test;
begin
  // Launch browser and open the Main page
  Browsers.Item(btIExplorer).Run('http://smartbear.com');
  // Test the Main page
  ...

  // Open the Products page
  Browsers.CurrentBrowser.Navigate('http://smartbear.com/products');
  // Test the Products page
  ...
end;

C++Script, C#Script

function Test()
{
  // Launch browser and open the Main page
  Browsers["Item"](btIExplorer)["Run"]("http://smartbear.com");
  // Test the Main page
  ...

  // Open the Products page
  Browsers["CurrentBrowser"]["Navigate"]("http://smartbear.com/products");
  // Test the Products page
  ...
}

See Also

BrowserInfo Object
Run Method
Navigate Operation
Launch Web Browsers
Running Tests in Multiple Browsers

Highlight search results