Changing tested application settings dynamically from the script

In some cases, the path to the tested application may vary from one computer to another. For example, installing the 32-bit application onto the 32-bit system, application shall default to the Program Files folder; and in case of 64-bit system, programs end up in the Program Files (x86) folder.

Another example of using dynamic paths is testing different versions of the same application, when the application path also includes the version number.

We can simply create two copies of the tested application in TestedApps and toggle-switch each one on and off, depending on the system type. Otherwise, we could define the pathname dynamically and modify it (along the other parameters) prior to the launch.

Getting ready

Add the Calculator Plus application to TestedApps.

How to do it...

In order to change the tested application's path we need to perform the following steps:

  1. The following example shows how we can change parameters of the application directly by scripting:
    function testChangeAppSettings()
    {
      if(Sys.OSInfo.Windows64bit)
      {
        TestedApps.CalcPlus.Path = "C:\Program Files (x86)\Microsoft Calculator Plus";
      }
      else
      {
        TestedApps.CalcPlus.Path = "C:\Program Files\Microsoft Calculator Plus";
      }
      TestedApps.CalcPlus.Run();
    }
  2. Launch it to verify that it is workable.

How it works...

Here we define the bitness of the system with the help of the Sys.OSInfo.Windows64bit property and set the path to the tested application depending on the value of the passed variable.

In a similar manner, we can change other application parameters as well (name, parameters, and so on).

Note

Before applying a certain property, read up on it in the reference book to make sure this property is not obsolete. Deprecated properties and methods are not recommended for use, as in the following versions of TestComplete they could be removed, for obsolescent properties and methods can be always replaced with more user-friendly alternatives.

..................Content has been hidden....................

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