DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk4 min

How to Select Radio Buttons with Selenium

Locate the intended radio input, wait until it is clickable, select it, and verify the result with Selenium’s selected-state API.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Find the intended radio input with a stable locator, wait until it is ready, click it, and verify the selection with Selenium’s selected-state method. In Python, that method is is_selected(); its casing differs in other Selenium language bindings.

Locate the exact radio option

Inspect the page’s markup and identify attributes that distinguish both the group and the option, such as id, name, and value. A selector for a specific option might look like input[name="plan"][value="premium"]; use it only if those attributes match the actual page.

As an Amazon Associate I earn from qualifying purchases.

Prefer a unique, stable ID when one exists. Otherwise, a concise CSS selector is often easy to read and maintain. XPath is useful when it makes a relationship or attribute match clearer, but avoid long absolute paths and selectors tied to incidental page structure. Selenium supports locator strategies including ID, name, CSS selector, and XPath; see the official locator guide and its locator practices.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Select and verify the radio button in Python

This example waits for the target radio to become clickable, clicks it, and checks that it is selected. Replace the locator with attributes from your page.

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

radio = WebDriverWait(driver, 10).until(
    EC.element_to_be_clickable((By.CSS_SELECTOR, 'input[name="plan"][value="premium"]'))
)
radio.click()
assert radio.is_selected()

The snippet assumes driver is an initialized WebDriver session and the page is already open. Selenium’s Python WebElement API documents is_selected() for checking selected state, including radio buttons; other bindings use their own method casing. See the Python WebElement API.

Understand radio groups and labels

Radio buttons represent a single choice from a set, unlike checkboxes, which allow independent choices. Inputs with the same name belong to a group; selecting one changes the selected option in that group. A radio may already be selected when the page loads, so assert the intended final state instead of assuming that every click caused a change.

You can also click the associated <label>. This can be practical when the input is visually small, provided you target the label associated with the option you intend to choose. The browser’s radio-control behavior and label association are described in MDN’s radio input reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Wait for dynamic controls before clicking

Navigation completing does not guarantee that a JavaScript-rendered radio has been inserted, displayed, or made interactable. Use an explicit wait for the condition needed at that step—such as locating the element or waiting until it is clickable—then click and verify the selected state.

Selenium warns, “Do not mix implicit and explicit waits.” Mixing them can make total wait durations unpredictable. Prefer a consistent synchronization strategy, usually explicit waits for the specific page state required. Fixed sleeps do not adapt to page speed: they may end too early or waste time when the control is ready sooner. See Selenium’s waiting strategies.

Troubleshoot selection failures

  • The wrong option is selected: make the locator specific to both the group and option, and confirm it matches the page’s actual attributes. Avoid selecting the first radio found if the page contains multiple groups.
  • No element is found: check the selector against the rendered page, and wait for JavaScript-driven content when necessary.
  • The click fails or is intercepted: confirm the element is displayed and enabled, and check for an overlay or other element covering it. Clicking the associated label may help when that is the page’s intended visible target.
  • The assertion fails: verify that the click targeted the intended option and that the assertion runs after the interaction. Remember that a radio may have been selected already or another same-named option may be selected instead.
  • Wait timing is erratic: avoid combining implicit and explicit waits. Wait for the relevant condition rather than adding an arbitrary long sleep.

Or skip the browser setup

If you need a screenshot of the page rather than a Selenium interaction test, ScreenshotNeo can return a screenshot or PDF from one API request. For example, this cURL request captures a page as WebP:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. It removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents take screenshots. The Free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. Sign up for free.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Frequently Asked Questions

Does clicking a radio button toggle it off?

No. Radio controls select one option in their group; selecting another option changes the group’s selected value.

Which Selenium method checks whether a radio is selected?

Use the selected-state API for your language binding; in Python, call `is_selected()`.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.