java - Unable to select text boxes of an particular column through XPath in selenium webdriver -


my java

package com.ej.zob.modules;  import java.util.list;  import org.openqa.selenium.by; import org.openqa.selenium.webelement;  public class revenue_month { public void execute() {     launchapplication.driver.findelement(by.linktext("view")).click();     launchapplication.driver.findelement(by.linktext("revenue")).click();     launchapplication.driver.findelement(by.name("click")).click();     list<webelement> c = launchapplication.driver.findelements(by.xpath("//a[contains(@id,'edit_')]"));     for(webelement elem_1:c)     {         elem_1.click();     }     list<webelement> w = launchapplication.driver.findelements(by.xpath("//td[position() = count(ancestor::table/tbody/tr/td[.='may']/preceding-sibling::*)+1]"));     //for(webelement elem:w)     //{     //  elem.     //  elem.sendkeys("50");     //  elem.click();     //}   }  } 

my html

<div id="idshowtable" style="background:#7f4f20"> <table id="maintable" border="1"> <tbody> <tr> <td align="center" colspan="14">state wise revenue of bank (all figures in inr , in lacs)</td> </tr> <tr> <td>state \ month</td> <td> <a href="#" onclick="">october</a> </td> <td> <a href="#" onclick="">november</a> </td> <td> <a href="#" onclick="">december</a> </td> <td> <a href="#" onclick="">january</a> </td> <td> <a href="#" onclick="">february</a> </td> <td> <a href="#" onclick="">march</a> </td> <td> <a href="#" onclick="">april</a> </td> <td> <a href="#" onclick="">may</a>  </td> <td> <a href="#" onclick="">june</a> </td> <td> <a href="#" onclick="">july</a> </td> <td> <a href="#" onclick="">august</a> </td> <td> <a href="#" onclick="">september</a> </td> <td> <a href="#" onclick="">operation</a> </td> </tr> <tr> <td>rajasthan</td> <td> <div> <input id="1_1" type="text" value="51838" style="width:50px" name="u1"> <br> <input type="button" value="update" onclick="fnupdaterevenue("1_1")" style="width:60px"> </div> </td> <td> <div> <input id="1_2" type="text" value="62192" style="width:50px" name="u1"> <br> <input type="button" value="update" onclick="fnupdaterevenue("1_2")" style="width:60px"> </div> </td> <td> <div> <input id="1_3" type="text" value="87617" style="width:50px" name="u1"> <br>  <input type="button" value="update" onclick="fnupdaterevenue("1_3")" style="width:60px"> </div> </td> <td> <div> <input id="1_4" type="text" value="59826" style="width:50px" name="u1"> <br> <input type="button" value="update" onclick="fnupdaterevenue("1_4")" style="width:60px"> </div> </td>   <td> <div> <input id="1_5" type="text" value="97075" style="width:50px" name="u1"> <br> <input type="button" value="update" onclick="fnupdaterevenue("1_5")" style="width:60px"> </div> </td> <td> <div> <input id="1_6" type="text" value="58818" style="width:50px" name="u1"> <br> <input type="button" value="update" onclick="fnupdaterevenue("1_6")" style="width:60px"> </div> </td> <td> <div> <input id="1_7" type="text" value="41250" style="width:50px" name="u1"> <br> <input type="button" value="update" onclick="fnupdaterevenue("1_7")" style="width:60px"> </div> </td> <td> <div> <input id="1_8" type="text" value="52233" style="width:50px" name="u1"> <br> <input type="button" value="update" onclick="fnupdaterevenue("1_8")" style="width:60px"> </div> </td> <td> <div> <input id="1_9" type="text" value="74272" style="width:50px" name="u1"> <br> <input type="button" value="update" onclick="fnupdaterevenue("1_9")" style="width:60px"> </div> </td>   <td> <div> <input id="1_10" type="text" value="28197" style="width:50px" name="u1"> <br> <input type="button" value="update" onclick="fnupdaterevenue("1_10")" style="width:60px"> </div> </td> <td> <div> <input id="1_11" type="text" value="79977" style="width:50px" name="u1"> <br> <input type="button" value="update" onclick="fnupdaterevenue("1_11")" style="width:60px"> </div> </td> <td> <div> <input id="1_12" type="text" value="11158" style="width:50px" name="u1"> <br> <input type="button" value="update" onclick="fnupdaterevenue("1_12")" style="width:60px"> </div> </td> <td> <a id="edit_1" href="#" onclick="fneditrevenue("1");" style="visibility: hidden;">edit</a> | <a id="hide_1" href="#" onclick="fnhiderevenue(1);" style="visibility: hidden;">hide</a> | <a id="show_1" href="#" style="visibility:hidden" onclick="fnshowrevenue(1);">show</a> </td> </tr> <tr> <td>sikkim</td> <td> <div> <input id="2_1" type="text" value="66503" style="width:50px" name="u2"> <br> <input type="button" value="update" onclick="fnupdaterevenue("2_1")" style="width:60px"> </div> </td> <td> <div> <input id="2_2" type="text" value="84033" style="width:50px" name="u2"> <br> <input type="button" value="update" onclick="fnupdaterevenue("2_2")" style="width:60px"> </div> </td> <td> <div> <input id="2_3" type="text" value="37062" style="width:50px" name="u2"> <br> <input type="button" value="update" onclick="fnupdaterevenue("2_3")" style="width:60px"> </div> </td> <td> <div> <input id="2_4" type="text" value="25780" style="width:50px" name="u2"> <br> <input type="button" value="update" onclick="fnupdaterevenue("2_4")" style="width:60px"> </div> </td> <td> <div> <input id="2_5" type="text" value="70574" style="width:50px" name="u2"> <br> <input type="button" value="update" onclick="fnupdaterevenue("2_5")" style="width:60px"> </div> </td>  <td> <div> <input id="2_6" type="text" value="99017" style="width:50px" name="u2"> <br> <input type="button" value="update" onclick="fnupdaterevenue("2_6")" style="width:60px"> </div> </td> <td> <div> <input id="2_7" type="text" value="1406" style="width:50px" name="u2"> <br>  <input type="button" value="update" onclick="fnupdaterevenue("2_7")" style="width:60px"> </div> </td> <td>  <div>  <input id="2_8" type="text" value="42724" style="width:50px" name="u2"> <br> <input type="button" value="update" onclick="fnupdaterevenue("2_8")" style="width:60px"> </div>  </td> <td> <div> <input id="2_9" type="text" value="22180" style="width:50px" name="u2"> <br>  <input type="button" value="update" onclick="fnupdaterevenue("2_9")" style="width:60px"> </div> </td>  <td> <div> <input id="2_10" type="text" value="27663" style="width:50px" name="u2"> <br> <input type="button" value="update" onclick="fnupdaterevenue("2_10")" style="width:60px"> </div> </td> <td> <div> <input id="2_11" type="text" value="88324" style="width:50px" name="u2"> <br> <input type="button" value="update" onclick="fnupdaterevenue("2_11")" style="width:60px"> </div> </td> <td> <div> <input id="2_12" type="text" value="42853" style="width:50px" name="u2"> <br> <input type="button" value="update" onclick="fnupdaterevenue("2_12")" style="width:60px">  </div> </td> <td>  <a id="edit_2" href="#" onclick="fneditrevenue("2");" style="visibility: hidden;">edit</a> |  <a id="hide_2" href="#" onclick="fnhiderevenue(2);" style="visibility: hidden;">hide</a> |  <a id="show_2" href="#" style="visibility:hidden" onclick="fnshowrevenue(2);">show</a> </td> </tr> 

i unable select text boxes in column particular month.

//td[position() = count(ancestor::table/tbody/tr/td[.='may']/preceding-sibling::*)+1] 

by xpath can select month name 'may' , trs.but want select column , specific input textboxes of intended column using month name.

your question little unclear guess. but, assume requirement find column , associated td using name of month. if so, try this:

//td[count(//td//a[contains(.,'october')]//.)] 

edit

since, want inputs type='text' add additional filtering;

//td[count(//td//a[contains(.,'october')]//.)]//input[@type='text'] 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -