logo       

selecting text right after a radio button using xpath: msg#00047

web.selenium.user

Subject: selecting text right after a radio button using xpath

Hello,

This is a tough one to crack.

My application generates a set of radio buttons dynamicaly like so

***********

<input type="radio" name="response_to_item.24306"
value="24310" id="show_item_form:elements:response_to_item.24306:24310"
checked="checked" /> MD<br>

<input type="radio" name="response_to_item.24306"
value="24311" id="show_item_form:elements:response_to_item.24306:24311" />
PhD<br>

<input type="radio" name="response_to_item.24306"
value="24312" id="show_item_form:elements:response_to_item.24306:24312" />
ScD<br>


<input type="radio" name="response_to_item.24306"
value="24313" id="show_item_form:elements:response_to_item.24306:24313" />
PharmD<br>

<input type="radio" name="response_to_item.24306"
value="24314" id="show_item_form:elements:response_to_item.24306:24314" />
EdD<br>

<input type="radio" name="response_to_item.24306"
value="24315" id="show_item_form:elements:response_to_item.24306:24315" />
RN<br>

<input type="radio" name="response_to_item.24306"
value="24316" id="show_item_form:elements:response_to_item.24306:24316" />
Other/Additional (please specify below)<br>

************

I need to click the radio button based on the text right after it. Selenium
allows me to click on a radio button by doing something like

click //input[@value='24310']

but the problem is that the values of the checkboxes are dynamically
generated, on the text after the dynamically generated radio button is not.

Is there a way to have selenium select the radio button that precedes a
matching string ?

For example I want to select the radio button that corresponds to 'MD'.

Thanks,

Hamilton


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise