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()
    List<WebElement> c = LaunchApplication.driver.findElements(By.xpath("//a[contains(@id,'Edit_')]"));
    for(WebElement elem_1:c)
    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();



<table id="mainTable" border="1">
<td align="center" colspan="14">State Wise Revenue of a Bank (all Figures are in INR and in Lacs)</td>
<td>State      Month</td>
<a href="#" onclick="">October</a>
<input id="1_1" type="text" value="51838" style="width:50px" name="U1"/>
<input type="button" value="Update" onclick="fnUpdateRevenue("1_1")" style="width:60px"/>

enter image description here

I am unable to select the text boxes in a column for a particular month.
“//td[position() = count(ancestor::table/tbody/tr/td[.=’May’]/preceding-sibling::*)+1]”
By this XPath I can select the month name say ‘may’ and its below cell.But I want to select Month Name ‘may’ with all its text boxes.through XPath.How to do this?Any Help?

Source: java

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.