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:

- UFT Developer JavaScript SDK Reference
- UFT Developer JavaScript SDK code samples

Tips to improve your search results... UFT Developer JavaScript SDK Reference Version 15.0-15.0.2 UFT Developer SDK Reference All View Local Help Center View Online Help Center back Go back in browser history forward Go forward in browser history Remove search highlights next topic Go to next topic previous topic Go to previous topic Print the current topic Version: