Share
Go down
sathya
Posts : 6
Join date : 2010-04-14

How do i get the ID or Xpath of Text from Dynamic table?

on Tue Apr 20, 2010 1:52 pm
Hi,

I have a dynamic table that has 220 rows and 22 col , out of which there are 2 col named ( LID and SVal) .I have to get the Sval for LID =2345



1) Currently i have got the Rowcount ;Rowcount = 220
2) Get the LID for each row

for (i = 1;i<=rowcount;i++)
{
j=17;( LID is in the 17th col)
String LID =selenium.getTable("xpath=//table[@id='ctl00_cphMasterPlaceHolder_grvTitleListDistribution']."+i+"."+j+"");

if (LID == 2345)
{
int x = 20;
String Svalue = selenium.getTable("xpath=//table[@id='ctl00_cphMasterPlaceHolder_grvTitleListDistribution']."+i+"."+x+"");
}

}

Although the above solution get me the Sval it is very very slow as i am using xpath becaz the table is dynamic and don't have a constant ID.

As i know i have to search for the value 2345 in the table , is there a way to get the ID or Xpath of the value"2345" and this will save from crawling to each row and this will be faster or can anybody suggest any other solution to this

Thanks in Advance !!!
metman
Amateur
Amateur
Posts : 58
Join date : 2010-04-02

Re: How do i get the ID or Xpath of Text from Dynamic table?

on Wed Apr 21, 2010 12:27 am
I'm not 100% sure on the solution, but I'd start by switching to getValue() and using xPath sibling keywords to get to the data cell you are looking for. I think what you are looking for is the equivalent code for "get the text of the 20th element in the row which has a 17th element containing the value 2345." Try something like:

selenium.getValue("preceding-sibling:://table[@id='ctl00_cphMasterPlaceHolder_grvTitleListDistribution']/tr/td[@value='2345'][3]"]);

That's not quite right I'd bet, but take that general idea.
Back to top
Permissions in this forum:
You cannot reply to topics in this forum