WPF code samples (JavaScript SDK)
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;
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); });
See also: