title: How to select radio button in selenium web driver java using text of nearby element in XPath
body: <p>I need to select radion button with <code>id="optProfile"</code> in 7th tr using text "Internet Users" in td/font tag. I am using below code but it is not working and selecting radio button from 1st tr row. Can anyone help</p>
  
  <pre><code>    &lt;html&gt;
  &lt;head&gt;
  &lt;body onmousedown="infCheckMouseDown(event);" onkeydown="infCheckDownKey(event);" onbeforeunload="INFIEExit();" onload="INFsetInitialFocus();window_onload();CreateScriptingFrames();"&gt;
  &lt;form action="PEINFCommon.ASP?WCI=Genericcreen&amp;WCE=GenericEvent" onsubmit="return false" name="Genericcreen" method="post"&gt;
  &lt;table class="TopLevelTable" align="center" width="100%" border="0"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;td width="100%"&gt;
  &lt;table width="100%" border="0"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;td width="100%"&gt;
  &lt;div align="center"&gt;
  &lt;center&gt;
  &lt;table width="98%" cellspacing="0" cellpadding="0" border="0" cols="1"&gt;
  &lt;tbody&gt;
  &lt;tr align="center"&gt;
  &lt;td align="left"&gt;
  &lt;table width="100%"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;tr height=""&gt;
  &lt;tr height=""&gt;
  &lt;tr height=""&gt;
  &lt;tr height=""&gt;
  &lt;tr height=""&gt;
  &lt;tr height=""&gt;
  &lt;tr height=""&gt;
  &lt;tr height=""&gt;
  &lt;tr height=""&gt;
  &lt;tr height=""&gt;
  &lt;tr height=""&gt;
  &lt;tr height=""&gt;
  &lt;td width="5%"&gt;
  &lt;input id="optProfile" type="Radio" callfunction="" value="" onblur="ResetScript(this);return true;" onfocus="HighlightScript(this);" onclick="" name="" size="11"&gt;
  &lt;font class="fLabel"&gt;&lt;/font&gt;
  &lt;br&gt;
  &lt;input id="hidCurrentProfile" type="hidden" onblur="ResetScript(this);" onfocus="HighlightScript(this);" value="N" callfunction="" size="11" name="/Root/ACORD/InsuranceSvcRs/nk_ck_com.cc_FetchUserProfileRs/nk_ck_com.cc_SecurityDetails/nk_ck_com.cc_AvailableProfile[12]/nk_ck_com.cc_CurrentProfileInd"&gt;
  &lt;input id="hidProfile" type="hidden" onblur="ResetScript(this);" onfocus="HighlightScript(this);" value="RACINTER" callfunction="" size="11" name="/Root/ACORD/InsuranceSvcRs/nk_ck_com.cc_FetchUserProfileRs/nk_ck_com.cc_SecurityDetails/nk_ck_com.cc_AvailableProfile[12]/nk_ck_com.cc_ProfileCd"&gt;
  &lt;/td&gt;
  &lt;td&gt;
  &lt;font class=""&gt;Internet Users&lt;/font&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height=""&gt;
  &lt;tr height=""&gt;
  &lt;tr height=""&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/center&gt;
  &lt;/div&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  &lt;/frame&gt;
  &lt;frame id="Script" scrolling="Yes" frameborder="0" noresize=""&gt;
  &lt;/frameset&gt;
  &lt;/html&gt;
  </code></pre>