I have got district names like these : Anantapur, Chittoor etc.. I have 13 districts. I have to click on each district. This is how HTML looks like:
</tr>
<tr class="gridRowStyle" align="center" style="color:#000066;">
<td>
1
</td>
<td align="left">
<a id="ctl00_ContentPlaceHolder1_Grid_Dist_ctl02_lnkbtnDist" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Grid_Dist$ctl02$lnkbtnDist','')">Anantapur</a>
</td>
<td align="right">
<span id="ctl00_ContentPlaceHolder1_Grid_Dist_ctl02_lblDman">63</span>
</td>
<td align="right">
<span id="ctl00_ContentPlaceHolder1_Grid_Dist_ctl02_lblMvill">2856</span>
</td>
<td align="right">
<span id="ctl00_ContentPlaceHolder1_Grid_Dist_ctl02_lblMcon">215441</span>
</td>
<td align="right">
<span id="ctl00_ContentPlaceHolder1_Grid_Dist_ctl02_lblDNExist">49681</span>
</td>
<td align="right">
<span id="ctl00_ContentPlaceHolder1_Grid_Dist_ctl02_lblDExist">165760</span>
</td>
<td align="right">
<span id="ctl00_ContentPlaceHolder1_Grid_Dist_ctl02_lblMupcon">215437</span>
</td>
<td align="right">
<span id="ctl00_ContentPlaceHolder1_Grid_Dist_ctl02_lblPer">100.00</span>
</td>
</tr>
<tr class="gridAlterRowStyle" align="center" style="color:#000066;">
<td>
2
</td>
<td align="left">
<a id="ctl00_ContentPlaceHolder1_Grid_Dist_ctl03_lnkbtnDist" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Grid_Dist$ctl03$lnkbtnDist','')">Chittoor</a>
I have tried Selenium to click on the text but somehow I am not able to do that.
Python
a=[2,14]
for i in a:
driver.find_element_by_xpath("//table[@id='ctl00_ContentPlaceHolder1_Grid_Dist']//tr[i]//td[2]").click()
driver.execute_script("window.history.go(-1)")
I need to click on the text Anantapur, Chittoor etc.. But it is not working. FYI: This is the website: http://65.19.149.160/gws/reports.aspx