Share this page

Set Method (IToggleButton)
Sets the value of this toggle button.

C# Syntax

    void Set(
       CheckedState state
    )

Parameters

state
  The value to be assigned to this toggle button. Possible values: HP.LFT.SDK.CheckedState.

Example

    // The following code example changes the state of the toggle button.

    [Test]
    public void TestWpfToggleButton()
    {
        // Identify the application and assign it to an IWindow object.
        var appMainWindow = Desktop.Describe<IWindow>(new WindowDescription
        {
            ObjectName = @"MainWindow",
            FullType = @"window",
            WindowTitleRegExp = @"MainWindow"
        });

        // Identify the WPF toggle button.
        var buttonWithToggleButtonSupport = appMainWindow.Describe<IButton>(new ButtonDescription
        {
            Text = @"Toggle Button",
            ObjectName = @"Button4"
        });
        IToggleButton toggleButton = buttonWithToggleButtonSupport.ToggleButton;

        // Sets the toggle button's state to checked.
        toggleButton.Set(CheckedState.Checked);

        // Changes the toggle button state.
        if (toggleButton.IsChecked)
        {
            toggleButton.Set(CheckedState.Unchecked);
        }
        else
        {
            toggleButton.Set(CheckedState.Checked);
        }
    }

Tips to improve your search results... OpenText™ Functional Testing for Developers .NET SDK Version: 25.2 OpenText™ Functional Testing for Developers SDK 25.2 All View Local Help Center View Online Help Center Version: