Login Object

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

The Login test object corresponds to the login dialog displayed by web browsers when the user attempts to access a web application that uses Basic authentication. You can use the UserName and Password properties of the Login object to automate filling out the credentials.

Important Notes
  • TestComplete may not be able to access the Login dialog displayed in Internet Explorer when you attempt to access protected resources that belong to a domain other than the domain to which the web page, which is currently open in the browser, belongs. To work around this problem, navigate to a web page (which does not require user authentication) belonging to an appropriate domain before accessing protected resources.

  • Cross-platform web tests cannot access the login dialogs. The Login object is not supported in such tests.

For more information on automating these dialogs, see Handle JavaScript Popups and Browser Dialogs.

Requirements

  • A license for TestComplete Web module.

  • The Web Testing plugin. This plugin is installed and enabled automatically. The plugin implements the Login test object, as well as the web testing functionality.

Members

Example

The following example demonstrates how to automate the login dialog.

JavaScript, JScript

function Test()
{
  var url = "http://secure.example.com";

  Browsers.Item(btIExplorer).Run(url);
  var page = Sys.Browser("*").Page(url);

  page.Login.UserName = "username";
  page.Login.Password = "password";
  // Or you can enter the user name and password using the text box object methods
  // page.Login.TextBox("UserName").SetText("username");
  // page.Login.TextBox("Password").SetText("password");

  page.Login.Button("OK").Click();

  page.Wait();
}

Python

def Test():
  url = "https://login.yahoo.com"

  Browsers.Item[btIExplorer].Run(url)
  page = Sys.Browser("*").Page(url)

  page.Login().UserName = "username"
  page.Login().Password = "password"
  # Or you can enter the user name and password using the text box object methods
  # page.Login.TextBox("UserName").SetText("username")
  # page.Login.TextBox("Password").SetText("password")

  page.Login().Button("OK").Click()

  page.Wait()

VBScript

Sub Test
  Dim url, page

  url = "http://secure.example.com"
  Browsers.Item(btIExplorer).Run url
  Set page = Sys.Browser("*").Page(url)

  page.Login.UserName = "username"
  page.Login.Password = "password"
  ' Or you can enter the user name and password using the text box object methods
  ' page.Login.TextBox("UserName").SetText("username")
  ' page.Login.TextBox("Password").SetText("password")

  page.Login.Button("OK").Click

  page.Wait
End Sub

DelphiScript

procedure Test;
var url, page;
begin
  url := 'http://secure.example.com/';

  Browsers.Item[btIExplorer].Run(url);
  page := Sys.Browser('*').Page(url);

  page.Login.UserName := 'username';
  page.Login.Password := 'password';
  // Or you can enter the user name and password using the text box object methods
  // page.Login.TextBox('UserName').SetText('username');
  // page.Login.TextBox('Password').SetText('password');

  page.Login.Button('OK').Click;

  page.Wait();
end;

C++Script, C#Script

function Test()
{
  var url = "http://secure.example.com";

  Browsers["Item"](btIExplorer)["Run"](url);
  var page = Sys["Browser"]("*")["Page"](url);

  page["Login"]["UserName"] = "username";
  page["Login"]["Password"] = "password";
  // Or you can enter the user name and password using the text box object methods
  // page["Login"]["TextBox"]("UserName")["SetText"]("username");
  // page["Login"]["TextBox"]("Password")["SetText"]("password");

  page["Login"]["Button"]("OK")["Click"]();

  page["Wait"]();
}

See Also

Testing Web Applications
Handle JavaScript Popups and Browser Dialogs
Alert Object
Confirm Object
Prompt Object

Highlight search results