Determine state of Google Chrome toggle switch

Hi.

I’m trying to determine the state of a toggle switch in the settings of Google Chrome.

image

I have successfully done this with Get Element for Checkboxes, however this activity doesn’t recognise the toggle control. I can use the selection tool to drag and select but this doesn’t work. Is there an activity I can use to determine if the toggle is turned on or off? I only want to click the setting if the value is set to On.

Hi @craig.norton

  1. Use ‘Find Element’ to locate the toggle switch
  2. Use ‘Get Attribute’ to get the ‘checked’ or ‘aria-checked’ attribute
  3. Use ‘If’ activity to check if the attribute value is True
    -If True: Use ‘Click’ activity to toggle the switch

Please make sure fine tune your selector.

Happy Automation

@craig.norton

this is not a checkbox..

try to indicate the element when toggle is on and off and check the differences in selector or properties in UI explorer and use that attribute in get attribute activity to determine the state

cheers

@craig.norton

try to use Check element activity to know the whether toggles is enabled or disabled

can you share the screenshots of all the available attributes (by using UiExplorer) ? I believe there should be at least one attribute changing when button is toggled.
I have checked via w3 school demo snippet the checked attribute was changing between 1 and 0
image