1

When i pass //input[@type='radio'] in the xpath, i'm able to select all the radio buttons in the list but i am not able to select a particular radio button by it's name. Name of the radio button is the fourth term in quotes inside the render_selected_term list.

<input type="radio" onclick="Element.show('indicator_radio_term_190');render_selected_term('190','1','275464','AQCB Number')" value="190" name="radio_190"/>
<input type="radio" onclick="Element.show('indicator_radio_term_179');render_selected_term('179','1','275464','AQCB Number (iLink)')" value="179" name="radio_179"/>
<input type="radio" onclick="Element.show('indicator_radio_term_19');render_selected_term('19','1','275464','Acceptance')" value="19" name="radio_19"/>
<input type="radio" onclick="Element.show('indicator_radio_term_148');render_selected_term('148','1','275464','Account (iLink)')" value="148" name="radio_148"/>
<input type="radio" onclick="Element.show('indicator_radio_term_206');render_selected_term('206','1','275464','Additional Non-standard Terms')" value="206" name="radio_206"/>
<input type="radio" onclick="Element.show('indicator_radio_term_220');render_selected_term('220','1','275464','Assigned Contract Manager (iLink)')" value="220" name="radio_220"/>
<input type="radio" onclick="Element.show('indicator_radio_term_12');render_selected_term('12','1','275464','Assignment')" value="12" name="radio_12"/>
<input type="radio" onclick="Element.show('indicator_radio_term_188');render_selected_term('188','1','275464','Authorized Purchasing Entity(ies)')" value="188" name="radio_188"/>
<input type="radio" onclick="Element.show('indicator_radio_term_226');render_selected_term('226','1','275464','Award (iLink)')" value="226" name="radio_226"/>
<input type="radio" onclick="Element.show('indicator_radio_term_196');render_selected_term('196','1','275464','Award Amount')" value="196" name="radio_196"/>
har07
  • 88,338
  • 12
  • 84
  • 137
Naveen Bharadwaj
  • 325
  • 1
  • 2
  • 12

2 Answers2

0

I would suggest you to use css selector in this case and attribute search. Be very careful when you use the following selector. The match you are looking for has to be unique.

Note: I am not sure which match you are looking for. So, I am showing you an example.

[onclick*='148']

Should match <input type="radio" name="radio_148" value="148" onclick="Element.show('indicator_radio_term_148');render_selected_term('148','1','275464','Account (iLink)')"/>

Saifur
  • 16,081
  • 6
  • 49
  • 73
0

Try this:

<div id="something">
<input type="radio" onclick="Element.show('indicator_radio_term_190');render_selected_term('190','1','275464','AQCB Number')" value="190" name="radio_190"/>
<input type="radio" onclick="Element.show('indicator_radio_term_179');render_selected_term('179','1','275464','AQCB Number (iLink)')" value="179" name="radio_179"/>


    IList<IWebElement> inputs = browser.FindElements(By.XPath("//div[@id='something']/input)");


    foreach(var element in inputs)
    {
       if(element.getAttribute("name").Equals("radio_12"))
         element.Click();
    }
Leon Barkan
  • 2,676
  • 2
  • 19
  • 43