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

<table id="mainTable" border="1">
<tbody>
<tr>
<td align="center" colspan="14">State Wise Revenue of a Bank (all Figures are in INR and in Lacs)</td>
</tr>
<tr>
<td>State      Month</td>
<td>
<a href="#" onclick="">October</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>

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