Running a tested application under a different user account

By default, TestComplete launches tested applications under the same user account under which TestComplete itself had been launched. At other times, however, it stands to reason one should be able to verify workability of the application under a different account name(s), for example, one with restricted permissions, and so on. To this end, the Run As option of the tested application has been specifically earmarked.

Getting ready

Create a new user in the system:

  1. Right-click on the Computer element in the main menu and opt for the Manage menu item.
  2. Expand the System Tools | Local Users and Groups | Users element.
  3. In the main menu, go for the Action | New User option.
  4. In the open New User window, enter a user name (for example, user1), a password and disable the User must change password at next logon option.
  5. Click on Create.

Add the Calculator Plus application to TestedApps and make sure it appears as a commonplace Windows application, as it's being launched (that is, the View | Classic View option has been enabled).

How to do it...

In order to run a tested application as a different user we need to perform the following steps:

  1. Double-click the TestedApps element and select the Calculator Plus in the right-hand pane.
  2. In the Basic Parameters section, select the Run As element in the Run Mode drop-down list.
  3. In the Run-Mode Parameters section, signify the name of the created user and the password.
    How to do it...
  4. Launch the application by either selecting the option Run from the contextual application menu in TestedApps, or by using the TestedApps.CalcPlus.Run()command in the script.
  5. Calculator Plus will start up with the default view (not the Classic View option).

How it works...

When we have changed the launching parameters of the calculator by setting the Classic View option, these customizations were saved for the current user. For a newly created user, it was the very first calculator application launch, and that's why default settings were applied. If we set the settings to Classic View once again (after calculator had been launched from under the user1 account name), the settings would have to be saved to be accounted for upon subsequent launches of the application.

There's more...

In order to launch the application from under another user, it is not entirely necessary to change application parameters, as one could simply apply the RunAs method of TestedApps. For example, in our example, the function call would look like this:

TestedApps.CalcPlus.RunAs("", "user1", "123456");
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.42.134