WPF code sample

Change a toggle button state

This example locates a toggle button and changes the toggle button state.

public void testWpfToggleButton() throws GeneralLeanFtException {			
 // Identify the application that has the toggle button.
 Window appMainWindow = Desktop.describe(Window.class, new WindowDescription.Builder().objectName("MainWindow").fullType("window").windowTitleRegExp("MainWindow").build());
 // Identify the button that supports the WPF toggle mechanism.
 Button buttonWithToggleButtonSupport = appMainWindow.describe(Button.class, new ButtonDescription.Builder().text("Toggle Button").objectName("Button4").build());			
 ToggleButton toggleButton = buttonWithToggleButtonSupport.getToggleButton();
 // Set the toggle button's state to checked.			
 // Change the toggle button state.
 if (toggleButton.isChecked()) {			
 } else {			

Back to top

See also: