Setting the UpDown Value

Applies to TestComplete 14.30, last modified on November 21, 2019

While testing UpDown controls, you can use specific properties and methods of the corresponding program object to perform certain actions and obtain data stored in controls. You can call these methods and properties from your keyword tests, as well as from scripts. This topic describes how to work with the needed properties and methods from your scripts. However, when testing a control from your keyword test, you can use the same methods and properties calling them from keyword test operations. For more information, see Keyword Tests Basic Operations.

You can set a value in the UpDown control's associated control by doing one of the following:

  • Assign a value to the wPosition property of the Win32UpDown object. During the test run, this object will be automatically associated with UpDown controls whose class names are listed in the project’s Object Mapping options. wPosition specifies the integer value that is currently displayed in the UpDown control's associated control.

    Below is an example that demonstrates how you can set an integer value in the Edit Box control used with the UpDown control:

    JavaScript, JScript

    function main()
    {
      var UpDown;

      // Obtain the UpDown control
      UpDown = Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("TUpDown", "", 1);

      // Set a value
      UpDown.wPosition = "15";
    }

    Python

    def Main():
    
      # Obtain the UpDown control 
      UpDown = Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("TUpDown", "", 1)
    
      # Set a value
      UpDown.wPosition = "15"

    VBScript

    Sub main
      Dim UpDown

      ' Obtain the UpDown control
      Set UpDown = Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("TUpDown", "", 1)

      ' Set a value
      UpDown.wPosition = "15"
    End Sub

    DelphiScript

    procedure Main;
    var UpDown;
    begin

      // Obtain the UpDown control
      UpDown := Sys.Process('Project1').Window('TForm1', 'Form1', 1).Window('TUpDown', '', 1);

      // Set a value
      UpDown.wPosition := '15';
    end;

    C++Script, C#Script

    function main()
    {
      var UpDown;

      // Obtain the UpDown control
      UpDown = Sys["Process"]("Project1")["Window"]("TForm1", "Form1", 1)["Window"]("TUpDown", "", 1);

      // Set a value
      UpDown["wPosition"] = "15";
    }

  • Simulate a mouse click on the up or down arrow button of the UpDown control using the Up and Down actions respectively. The Up and Down actions simulate moving the mouse pointer to the up or down arrow button of the UpDown control and then simulate a mouse click on it. Clicking the up arrow increases the current value, clicking the down arrow decreases the value.

    JavaScript, JScript

    function main()
    {
      var UpDown;

      // Obtain the UpDown control
      UpDown = Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("TUpDown", "", 1);

      // Set a value
      UpDown.Up();
      UpDown.Up();
      UpDown.Down();
    }

    Python

    def Main():
    
      # Obtain the UpDown control 
      UpDown = Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("TUpDown", "", 1)
    
      # Set a value
      UpDown.Up()
      UpDown.Up()
      UpDown.Down()

    VBScript

    Sub main
      Dim UpDown

      ' Obtain the UpDown control
      Set UpDown = Sys.Process("Project1").Window("TForm1", "Form1", 1).Window("TUpDown", "", 1)

      ' Set a value
      UpDown.Up
      UpDown.Up
      UpDown.Down
    End Sub

    DelphiScript

    procedure Main;
    var UpDown;
    begin

      // Obtain the UpDown control
      UpDown := Sys.Process('Project1').Window('TForm1', 'Form1', 1).Window('TUpDown', '', 1);

      // Set a value
      UpDown.Up;
      UpDown.Up;
      UpDown.Down;
    end;

    C++Script, C#Script

    function main()
    {
      var UpDown;

      // Obtain the UpDown control
      UpDown = Sys["Process"]("Project1")["Window"]("TForm1", "Form1", 1)["Window"]("TUpDown", "", 1);

      // Set a value
      UpDown["Up"]();
      UpDown["Up"]();
      UpDown["Down"]();
    }

See Also

Working With UpDown Controls
wPosition Property (UpDown Controls)
Up Action (Up-Down Controls)
Down Action (UpDown Controls)

Highlight search results