How to check if toggle button is selected or not in Truclient
Unlike a checkbox which is pretty standard, there are different implementations to toggle buttons. Usually the on/off indication is managed by CSS (HTML Styling), hence it is not straight forward to generalize it to a simple API.
In W3Schools example the on/off indication is done by CSS using background color indication and the location of the toggle of the button inside the background, which is also controlled by CSS. Behind the scenes there is also a hidden checkbox that maintains the state.
// Get the object style since the toggle is visualized using background-color
// The object is identified by TruClient. This is the object identified in the Object section
var style = window.getComputedStyle(object);
// get the background color value var bgcolor = style.getPropertyValue('background-color');
// rgb(33, 150, 243) means checked in this example if (bgcolor == "rgb(33, 150, 243)") window.alert("checked") else window.alert(bgcolor)
You can write your own code in the if/else sections based on your desired logic. Alternatively you can use also TruClient If/Else step and control the flow based on the toggle button state.
You will probably have to examine the DOM in your application and reach to the concrete logic required for your application
I know it is not trivial, but it is not that hard either.
Hope it helps