URL Property (Page Objects)

Applies to TestComplete 15.62, last modified on March 19, 2024

Description

Use the URL property to get the URL of the web page to which the Page object corresponds.

Declaration

TestObj.URL

Read-Only Property String
TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section

Applies To

The property is applied to the following object:

View Mode

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

Property Value

A string holding the web page’s URL.

Remarks

You can also determine the web page’s URL by using the URL property of the parent window object of the Page object.

Example

The following example demonstrates how you can obtain the URL of the web page currently opened in a web browser.

JavaScript, JScript

function URLSample()
{

  var url = "http://smartbear.com/";
  Browsers.Item(btIExplorer).Run(url);
  var browser = Sys.Browser("iexplore");

  …

  // Obtains the page currently opened in the browser
  var page = browser.Page("*");
  // Posts the URL of the currently open page to the log
  Log.Message(page.URL);

  …

}

Python

def URLSample():
  url = "http://smartbear.com/"
  Browsers.Item[btIExplorer].Run(url)
  browser = Sys.Browser("iexplore")

  # ...

  # Obtains the page currently opened in the browser
  page = browser.Page("*")
  # Posts the URL of the currently open page to the log
  Log.Message(page.URL)

  # ...

VBScript

Sub URLSample

  url = "http://smartbear.com/"
  Browsers.Item(btIExplorer).Run(url)
  Set browser = Sys.Browser("iexplore")

  …

  ' Obtains the page currently opened in the browser
  Set page = browser.Page("*")
  ' Posts the URL of the currently open page to the log
  Log.Message page.URL

  …

End Sub

DelphiScript

procedure URLSample();
var url, browser, page;
begin

  url := 'http://smartbear.com/';
  Browsers.Item[btIExplorer].Run(url);
  browser := Sys.Browser('iexplore');

  …
  // Obtains the page currently opened in the browser
  page := browser.Page('*');
  // Posts the URL of the currently open page to the log
  Log.Message(page.URL);

  …

end;

C++Script, C#Script

function URLSample()
{

  var url = "http://smartbear.com/";
  Browsers["Item"](btIExplorer)["Run"](url);
  var browser = Sys["Browser"]("iexplore");

  …

  // Obtains the page currently opened in the browser
  var page = browser["Page"]("*");
  // Posts the URL of the currently open page to the log
  Log["Message"](page["URL"]);

  …

}

See Also

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

Highlight search results