Treating Complex User Interface (UI) Widgets Like Finite State Machines