"Click element" for website toggle selection to always be in "On" position.

Hello, I am trying to create a snippet that will adjust a slide toggle selection in a website to the "On" position ONLY if the toggle is NOT already selected. Sometimes when i come to the site the slide toggle selection is already selected as "Off" and sometimes it is already selected in the "On" position. The selection when I come to the site is variable. I always want the selection to end up in the "On" position. I am trying to use the "Click element" command however if the slide toggle on the website is in the "On" position to begin with, the command will turn it "Off" (not desired). Is there a command or series of commands that could help address this issue? Thank you for your help.
Off Toggle
On Toggle

Hi, and welcome to the forum! :slight_smile:

The general approach would be to use the {site} command to get the value of the toggle and the use an {if} command to determine whether to toggle it based on that value

Can you share a link to the site? We might be able to provide more specific guidance with it.

Hello, thanks for the guidance. It is for creating an eBay.com listing. The page titled "Complete your listing". Since it is within my Seller account, the best link would be to start at List an item | eBay and navigate to a page called "Complete your listing". Thank you for your time.

Hi @rjonah8 ,

Thanks for sharing the details. Try something like this:

{if: catch({site: text; page=https://www.ebay.com/\*; selector=[name="bestOfferEnabled"]:checked; frame=top},"ERR")="ERR"}{click: selector=[name="bestOfferEnabled"]; frame=top}{endif}

This snippet works on the "Allow offers" checkbox.

I understand it's not the simplest way to approach this use case. We'll look into how we can simplify this flow. Thanks for your feedback.

Hello, unfortunately the snippet did not work for the "Allow Offers" toggle and also I am looking to toggle the "Promote Listing" General toggle into the on position (if it is already in the on position, I do not want to toggle it off).

Any advice is much appreciated. Thank you.

Thanks for letting me know. Here is the updated snippet:

Command to enable best offer:
{if: catch({site: text; page=https://www.ebay.com/\\*; selector=[name="bestOfferEnabled"]:checked; frame=top},"ERR")="ERR"}{click: selector=[name="bestOfferEnabled"]; frame=top}{endif}

Command to enable scheduling selection:
{if: catch({site: text; page=https://www.ebay.com/\\*; selector=[name="scheduleListingSelection"]:checked; frame=top},"ERR")="ERR"}{click: selector=[name="scheduleListingSelection"]; frame=top}{endif}

Command to enable General Promote Listing:
{if: catch({site: text; page=https://www.ebay.com/\\*; selector=[name="Toggle General"]:checked; frame=top},"ERR")="ERR"}{click: selector=[name="Toggle General"]; frame=top}{endif}

As you can see in each part, I'm only changing the part inside "name=".

This is how it looks to me on eBay:


If it looks different for you, please do the following:

  1. Right-click inside the radio button
  2. Select the "Inspect" option - which is usually the last option in the menu.
  3. A panel will open on the right side.
  4. Now take a screenshot of the Chrome window

Please send me this screenshot, so I can find the name of the input element that we want to click on.