Page Method (Browser and Process Objects)

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

The Page method returns a Page object that corresponds to the opened web page with the specified URL.

This method is added to processes that correspond to the supported web browsers as well as to the WPF Host process (PresentationHost) that executes WPF XAML Browser applications (XBAP). The method is available only when the Web Testing plugins are installed in TestComplete.

Declaration

TestObj.Page(URL, Index)

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    
Index [in]    Optional    Integer Default value: 0   
Result A Page object

Applies To

The method is applied to the following objects:

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

Specifies the URL of the web page opened in the browser. You can use wildcard characters (* and ?) or regular expressions in the ”regexp:pattern“ format to indicate the dynamic parts of the URL, such as values of the query string variables:

Sys.Browser("iexplore").Page("http://www.example.com/index.asp?sid=*")

The asterisk (*) corresponds to a string of any length, the question mark (?) corresponds to any single character. To specify more complicated parts of a URL, use regular expressions:

Sys.Browser("iexplore").Page("regexp:http://www.example.(com)|(net)|(org)/index.asp\?sid=.*")

Index

This parameter is only used if you open two or more pages with the same URL in the browser. In this case, these pages have the same URL, so to distinguish the pages, TestComplete uses the Index parameter. The parameter specifies the order in which the pages were opened. If there is only one page with the specified URL, the Index parameter is not used.

Result Value

The Page object that corresponds to the browser control displaying a page with the specified URL.

If no page is found, the Page method returns an empty stub object. You can use the Exists property of the returned object to check whether the page exists.

We do not recommend calling the Exists property in a loop to wait for a page. Use the WaitPage method instead. See also Wait For Web Pages.

Remarks

  • To open a new web page in a browser, use the ToUrl method.

  • During recording, TestComplete can ignore values of specific query string variables in the web page URL and replace them with the * wildcard in the recorded script. To enable this feature, use the Ignore dynamic URL parameters project option.

Example

The following example demonstrates how to use the Page method in scripts:

JavaScript, JScript

function WebSample()
{

  Browsers.Item(btIExplorer).Run("http://smartbear.com/");

  // Obtains the browser process
  var browser = Sys.Browser("iexplore");
  // Obtains the page currently opened in Internet Explorer
  var page = browser.Page("*");

}

Python

def WebSample():

  Browsers.Item[btIExplorer].Run("http://smartbear.com/");

  # Obtains the browser process
  browser = Sys.Browser("iexplore");
  # Obtains the page currently opened in Internet Explorer
  page = browser.Page("*");

VBScript

Sub WebSample

  Browsers.Item(btIExplorer).Run("http://smartbear.com/")

  ' Obtains the browser process
  Set browser = Sys.Browser("iexplore")
  ' Obtains the page currently opened in Internet Explorer
  Set page = browser.Page("*")

End Sub

DelphiScript

procedure WebSample();
var browser, page;
begin

  Browsers.Item(btIExplorer).Run('http://smartbear.com/');

  // Obtains the browser process
  browser := Sys.Browser('iexplore');
  // Obtains the page currently opened in Internet Explorer
  page := browser.Page('*');

end;

C++Script, C#Script

function WebSample()
{

  Browsers["Item"](btIExplorer)["Run"]("http://smartbear.com/");

  // Obtains the browser process
  var browser = Sys["Browser"]("iexplore");
  // Obtains the page currently opened in Internet Explorer
  var page = browser["Page"]("*");

}

See Also

Classic Web Testing
Page Object
WaitPage Method (Process Objects)
Page Method (Window Objects)
ToUrl Method (Browser Objects)
Navigate to Web Pages
Wait For Web Pages

Highlight search results