javascript - Need suggestion to code for filter icon -


i need code in selenium web drive java below code. using java eclipse. trying find element filter menu. once click filter icon filter menu displayed. when try find element clicking filter icon using firebug below code got highlighted span class="k-icon k-filter xpath not working.

<th class="k-header k-filterable k-with-icon" scope="col" data-title="package detail" data-index="0" data-field="packagedetail.namee" data-role="columnsorter">  <a class="k-grid-filter" href="javascript:void(0)" tabindex="-1">   <span class="k-icon k-filter"/>  </a>  <a class="k-link" href="/valiadationrule/getdata?valiadationrulegrid-sort=packagedetail.namee-asc">package detail</a> </th>  <th class="k-header k-filterable k-with-icon" scope="col" data-title="category" data-index="1" data-field="category" data-role="columnsorter">  <a class="k-grid-filter" href="javascript:void(0)" tabindex="-1">   <span class="k-icon k-filter"/> </a> <a class="k-link" href="/valiadationrule/getdata?valiadationrulegrid-sort=category-asc">category</a> </th>  <th class="k-header k-filterable k-with-icon" scope="col" data-title="name" data-index="2" data-field="name" data-role="columnsorter">  <a class="k-grid-filter" href="javascript:void(0)" tabindex="-1">    <span class="k-icon k-filter"/>  </a>  <a class="k-link" href="/valiadationrule/getdata?valiadationrulegrid-sort=name-asc">name</a> </th> 

try either of below java codes click on first filter icon "package detail":

//a[.='package detail'] 

it select element tag a , exact innerhtml/text package detail.

or

//a[contains(@href,'packagedetail')] 

it select element tag a , href attribute containing text packagedetail.


edit

based on latest image, have figured out problem was. actually, whole grid inside frame id bodyframe. hence, have first switch frame, before clicking on filter icon.

1- switching frame:

driver.switchto().frame("bodyframe"); 

2- clicking on filter icon:

driver.findelement(by.xpath("//a[contains(@href,'packagedetail')]/preceding-sibling::a")).click(); 

or

driver.findelement(by.xpath("//th[@data-title='package detail']//span[@class='k-icon k-filter']/..")).click(); 

or

 driver.findelement(by.xpath("//th[@data-title='package detail']//span[@class='k-icon k-filter']")).click(); 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -