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
mkunda
Posts : 4
Join date : 2010-03-21

Retrieving number of rows in a table Empty Retrieving number of rows in a table

Sun Mar 21, 2010 12:59 am
Hi

I am new to Selenium. I am using Selenium with Java. I would like to retrieve number of rows of a table and need to retrieve content of each row of a specific column to validate. I can identify the table only with "id" property. But that ID property is not consistent. And I don't have any other property to identify the table.

Please help me out.

Thanks in advance
Advisor
Advisor
------------------------
------------------------
Posts : 387
Join date : 2009-07-30
Location : India
https://seleniumforum.forumotion.net

Retrieving number of rows in a table Empty Re: Retrieving number of rows in a table

Sun Mar 21, 2010 11:29 am
avatar
mkunda
Posts : 4
Join date : 2010-03-21

Retrieving number of rows in a table Empty Re: Retrieving number of rows in a table

Sun Mar 21, 2010 2:19 pm
Thanks for the quick response. I have seen the post. But I dont under stand how to use this statement.
I am trying in the following way
Selenium sel = new Selenium();
s=sel.storeXpathCount("");
But I coudnt see any predefined method called storeXpathCount with Selenium. Do I need any Jar file for this.

Thanks in Advance
Advisor
Advisor
------------------------
------------------------
Posts : 387
Join date : 2009-07-30
Location : India
https://seleniumforum.forumotion.net

Retrieving number of rows in a table Empty Re: Retrieving number of rows in a table

Mon Mar 22, 2010 1:19 pm
yes , you have to call selenium-server.jar into your code so that all function/API of selenium core can be accessible to you.

Checkout this post to get an idea:
https://seleniumforum.forumotion.net/selenium-rc-discussion-f4/can-t-make-rc-code-to-run-t165.htm
avatar
mkunda
Posts : 4
Join date : 2010-03-21

Retrieving number of rows in a table Empty Re: Retrieving number of rows in a table

Tue Mar 23, 2010 11:22 am
Hi Adviser,

thanks for the quick reply I have added all the libraries. I am able to see sel.getXpathCount. But I am not able to see sel.storeXpathCount.

Actually I wanted to validated a text field value and as well as a table cell value.

I have added the following jar files
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;

import junit.framework.TestCase;
import org.openqa.selenium.*;
import org.openqa.selenium.server.SeleniumServer;

Could you tell me the exact steps or code for this.
Sorry to ask too much in details .
avatar
metman
Amateur
Amateur
Posts : 58
Join date : 2010-04-02

Retrieving number of rows in a table Empty Re: Retrieving number of rows in a table

Sat Apr 03, 2010 1:39 am
Yeah, just use:

int rowCount = sel.getXpathCount(XPathToTRElements).intValue();

getXpathCount returns a Number object, but ints are usually easier to deal with in circumstances like this. Also, if you are more interested in the aggregate contents of a column than the number of rows, you can also implicitly wildcard address all table cells in all rows by using an XPath like pathToHeadOfTable/tr/td[x] where x is the cell index across all rows. Be aware that spans may mess up using a path like that though.

Edit: scratch that, I forgot Selenium doesn't have a nice way of dumping out content of a wildcard path like that. So yeah, you'd have to loop through the rows with getXPathCount() and pull out the individual tds to validate 1 by 1.
Sponsored content

Retrieving number of rows in a table Empty Re: Retrieving number of rows in a table

Back to top
Permissions in this forum:
You cannot reply to topics in this forum