I want to click the radio button of the item that matches my grant number. The issue is that the HTML seems to have some numbers before it that I don't know until I search. For example, if I search for ABC-2202
, the HTML might look something like this:
<input type="Radio" name="PanelGroup" id="PanelGroup" value="225,ABC-2202" title="Panel Group">
I want to find and click the radio button that ends with my phrase because there also exists some results like ABC-2202-A
, ABC-2202-B
, etc.
I have already tried the following (which I found in other questions on Stackoverflow), with the variable:
grant = 'ABC-2202'
then
driver.find_element(By.XPATH,"//input[substring(@value, string-length(@value) - string-length(grant) +1) = grant]".click()
and
driver.find_element(By.CSS_SELECTOR, "input[type='radio'][value$=grant]").click()
but neither of these has worked for me.