Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

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

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

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 !!!
avatar
metman
Amateur
Amateur
Posts : 58
Join date : 2010-04-02

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

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