Share this page

# WPF code samples (JavaScript SDK)

In this topic:

## Var declarations for WPF test script

This example shows var declarations for WPF test script.

    var LFT = require("leanft");
    var expect = require("leanft/expect");
    var WPF = LFT.WPF;
    var Desktop = LFT.Desktop;
    var CheckedState = LFT.CheckedState;

Back to top

## Locate toggle button and change state

This example shows how to locate a toggle button and change the toggle button state.

    it("ToggleButton example", function (done) {
    	// Identify the application that has the toggle button.
    	var appMainWindow = Desktop.$(WPF.Window({
    		objectName:"MainWindow",
    		fullType:"window",
    		windowTitleRegExp:"MainWindow"
    	}));

    	// Identify the button that supports the WPF toggle mechanism.
    	var buttonWithToggleButtonSupport = appMainWindow.$(WPF.Button({
    		text:"Toggle Button",
    		objectName:"Button4"
    	}));

    	var toggleButton = buttonWithToggleButtonSupport.toggleButton();
    	toggleButton.set(CheckedState.checked); // Example for setting the toggle button's state to "checked"

    	// Change the toggle button state.
    	toggleButton.isChecked().then(function (isChecked) {
    		if (isChecked) {
    			toggleButton.set(CheckedState.unchecked);
    		} else {
    			toggleButton.set(CheckedState.checked);
    		}
    	});

    	LFT.whenDone(done);
    });

Back to top

See also:

- JavaScript SDK
- JavaScript SDK code samples

https://admhelp.microfocus.com Functional Testing for Developers 8942
Tips to improve your search results... OpenText™ Functional Testing for Developers Help Center OpenText™ Functional Testing for Developers Help 25.2 All View Local Help Center View Online Help Center Version: