Rebooting the Computer During Automated Testing

Applies to TestComplete 15.70, last modified on December 17, 2024
Information in this topic applies to desktop and web applications.

TestComplete lets you reboot the computer during automated testing. After it is rebooted, TestComplete can continue running the test from a specific script function.

You can also shut down or reboot the computer at the end of the test -- see Shutting Down and Restarting Computer After Test Run.

About RebootAndContinue

To reboot the computer during automated testing, use the aqEnvironment.RebootAndContinue method. In keyword tests, you can call this method using the Call Object Method or Run Code Snippet operation.

JavaScript, JScript

aqEnvironment.RebootAndContinue("UnitName.FunctionName", "password", "username", "domain");

Python

aqEnvironment.RebootAndContinue("UnitName.FunctionName", "password", "username", "domain")

VBScript

Call aqEnvironment.RebootAndContinue("UnitName.FunctionName", "password", "username", "domain")

DelphiScript

aqEnvironment.RebootAndContinue('UnitName.FunctionName', 'password', 'username', 'domain');

C++Script, C#Script

aqEnvironment["RebootAndContinue"]("UnitName.FunctionName", "password", "username", "domain");

The aqEnvironment.RebootAndContinue method reboots the computer, logs in and continues the test run from the specified script function of the current test project. This function must meet the following conditions:

  • It must have no parameters. To pass data to this function, you can use project or project suite variables, or read data from a file.

  • It must prepare the environment and the tested application for further testing: run the tested application, bring it to the needed state, initialize global script variables and so on.

Tip: To run a keyword test after rebooting the computer, create a wrapper script function that will call this keyword test and specify this function in the RebootAndContinue call.

Logging In After Restart

The aqEnvironment.RebootAndContinue method lets you log in using the credentials of the current user account or of another account.

To log in using the current account, specify just the password:

JavaScript, JScript

aqEnvironment.RebootAndContinue("UnitName.FunctionName", "password");

Python

aqEnvironment.RebootAndContinue("UnitName.FunctionName", "password")

VBScript

Call aqEnvironment.RebootAndContinue("UnitName.FunctionName", "password")

DelphiScript

aqEnvironment.RebootAndContinue('UnitName.FunctionName', 'password');

C++Script, C#Script

aqEnvironment["RebootAndContinue"]("UnitName.FunctionName", "password");

If the current account has empty password, do not specify any user account information:

JavaScript, JScript

aqEnvironment.RebootAndContinue("UnitName.FunctionName");

Python

aqEnvironment.RebootAndContinue("UnitName.FunctionName")

VBScript

Call aqEnvironment.RebootAndContinue("UnitName.FunctionName")

DelphiScript

aqEnvironment.RebootAndContinue('UnitName.FunctionName');

C++Script, C#Script

aqEnvironment["RebootAndContinue"]("UnitName.FunctionName");

To log in using another user account, specify the domain, user name and password:

JavaScript, JScript

aqEnvironment.RebootAndContinue("UnitName.FunctionName", "password", "user", "domain");

Python

aqEnvironment.RebootAndContinue("UnitName.FunctionName", "password", "user", "domain")

VBScript

Call aqEnvironment.RebootAndContinue("UnitName.FunctionName", "password", "user", "domain")

DelphiScript

aqEnvironment.RebootAndContinue('UnitName.FunctionName', 'password', 'user', 'domain');

C++Script, C#Script

aqEnvironment["RebootAndContinue"]("UnitName.FunctionName", "password", "user", "domain");

Tip: To avoid storing passwords in your tests as plain text, use one of the techniques described in Working With Passwords and Other Sensitive Data.

How RebootAndContinue Works

The aqEnvironment.RebootAndContinue method does the following:

  • Saves the user account information to this registry key:

    HKEY_USERS\{USER_SID}\Software\Microsoft\Windows\CurrentVersion\RunOnce

    where {USER_SID} is the ID of this user account.

  • Logs off the current user.

  • Reboots the computer.

  • Logs in automatically using the account saved in the registry.

  • Starts TestComplete.

  • Removes its data from the above-mentioned registry key.

    Note: If this data is not removed (for example, if TestComplete was terminated or if the logged in user does not have permissions for this key), this user account may be used next time Windows starts.
  • Opens the same test project in TestComplete and runs the specified script function.

Requirements

  • You must run TestComplete as an administrator to use RebootAndContinue.

  • The following registry key must exist:

    HKEY_USERS\{USER_SID}\Software\Microsoft\Windows\CurrentVersion\RunOnce

    where {USER_SID} is the ID of the user account used to log in after restart. This user must have permissions to create and delete values in this key.

  • Windows must not show a legal notice message before the logon screen is displayed (this message cannot be closed automatically). To disable the legal notice, set blank values for the following registry keys:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\LegalNoticeCaption
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\LegalNoticeText

See Also

Running Tests
RebootAndContinue Method
Shutting Down and Restarting Computer After Test Run

Highlight search results