Skip to content

Element Cookbook

Control-by-control snippets, organised by category. Each shows the original FlaUI C# call (from the FlaUI UITests) and its Python equivalent. For full, runnable suites that string these together, see the Examples overview.

All snippets assume a window (an automation element / Window) and a condition factory cf — see any example suite for how to obtain them.

Interactive controls

Button

var button = window.FindFirstByXPath("//Button[@Name='OK']").AsButton();
button.Invoke();
button = window.find_first_by_x_path("//Button[@Name='OK']").as_button()
button.invoke()

CheckBox

var cb = window.FindFirstDescendant(cf => cf.ByAutomationId("accept"))?.AsCheckBox();
cb.Toggle();
cb = window.find_first_descendant(cf.by_automation_id("accept")).as_check_box()
cb.toggle()

RadioButton

var radio = window.FindFirstDescendant(cf => cf.ByAutomationId("RadioButton1"))?.AsRadioButton();
radio.IsChecked = true;
radio = window.find_first_descendant(cf.by_automation_id("RadioButton1")).as_radio_button()
radio.is_checked = True

ComboBox

var combo = window.FindFirstDescendant(cf => cf.ByAutomationId("Countries"))?.AsComboBox();
combo.Select("India");
combo = window.find_first_descendant(cf.by_automation_id("Countries")).as_combo_box()
combo.select("India")

TextBox

var textBox = window.FindFirstDescendant(cf => cf.ByAutomationId("TextBox"))?.AsTextBox();
textBox.Text = "hello";
text_box = window.find_first_descendant(cf.by_automation_id("TextBox")).as_text_box()
text_box.text = "hello"

Slider

var slider = window.FindFirstDescendant(cf => cf.ByAutomationId("Slider"))?.AsSlider();
slider.Value = 7;
slider = window.find_first_descendant(cf.by_automation_id("Slider")).as_slider()
slider.value = 7

Containers

ListBox

var listBox = window.FindFirstDescendant(cf => cf.ByAutomationId("ListBox"))?.AsListBox();
listBox.Select(0);
list_box = window.find_first_descendant(cf.by_automation_id("ListBox")).as_list_box()
list_box.select(0)

Tree

var tree = window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Tree))?.AsTree();
var node = tree.Items[0];
node.Expand();
tree = window.find_first_descendant(cf.by_control_type(ControlType.Tree)).as_tree()
node = tree.items[0]
node.expand()

Grid / DataGrid

var grid = window.FindFirstDescendant(cf => cf.ByControlType(ControlType.DataGrid))?.AsGrid();
var cell = grid.Rows[0].Cells[1];
grid = window.find_first_descendant(cf.by_control_type(ControlType.DataGrid)).as_grid()
cell = grid.rows[0].cells[1]

Tab

var tab = window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Tab))?.AsTab();
tab.SelectTabItem("Complex Controls");
tab = window.find_first_descendant(cf.by_control_type(ControlType.Tab)).as_tab()
tab.select_tab_item(value="Complex Controls")  # or select_tab_item(index=1)

Display

Label

var label = window.FindFirstDescendant(cf => cf.ByAutomationId("Label"))?.AsLabel();
var text = label.Text;
label = window.find_first_descendant(cf.by_automation_id("Label")).as_label()
text = label.text

ProgressBar

var bar = window.FindFirstDescendant(cf => cf.ByAutomationId("ProgressBar"))?.AsProgressBar();
var value = bar.Value;
bar = window.find_first_descendant(cf.by_automation_id("ProgressBar")).as_progress_bar()
value = bar.value

Windows & dialogs

var dialog = window.ModalWindows.First();
dialog.Close();
dialog = window.modal_windows[0]
dialog.close()

Title bar

var titleBar = window.TitleBar;
titleBar.MinimizeButton.Invoke();
title_bar = window.title_bar
title_bar.minimize_button.invoke()