'select radio button in selenium using python

I tried driver.find_element(By.XPATH, "//input[@value='option1']").click

But Error message generated

Note:

  1. value attributes is not supported by find_element

  2. ID is not available as an attribute

Below is the HTML code

label _ngcontent-c12="" class="custom-control custom-radio"

input _ngcontent-c12="" class="custom-control-input input-md input-rectangle ng-dirty ng-valid ng-touched"  formcontrolname="radioBtns" name="radioBtns" nbinput="" type="radio" value="option1"

span _ngcontent-c12="" class="custom-control-description">


Solution 1:[1]

You'd better use find_element_by_css_selector function.

driver.find_element_by_css_selector("input[value='option1']").click()

Hope it could help.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David Lu