Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Selenium WebDriver Integration
Tue Nov 21, 2017 1:06 pm by azharuddin

» how to connect DB in selenium webriver
Fri Oct 06, 2017 4:09 pm by anbarasi

» How find any text in browser screen and click on it?
Thu Oct 05, 2017 2:02 pm by sandeepkommineni

» Selenium Webdriver
Tue Oct 03, 2017 1:35 pm by PiyushBiswas

» GRID setup tutorial.
Wed Sep 27, 2017 4:29 pm by johnyapp

» Drag & Drop Between Windows Using Selenium Driver
Wed Sep 27, 2017 2:10 pm by 26rondel

» Check if window is closed / verify input
Sat Sep 23, 2017 10:21 pm by brainstir

» How to work on pages with AJAX in selenium?
Mon Sep 18, 2017 6:08 pm by azharuddin

» pause test until user press a key like F2
Wed Aug 09, 2017 11:10 pm by djnforce

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Retrieving number of rows in a table

View previous topic View next topic Go down

Retrieving number of rows in a table

Post by mkunda on 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

mkunda

Posts : 4
Join date : 2010-03-21

Back to top Go down

Re: Retrieving number of rows in a table

Post by Adviser on Sun Mar 21, 2010 11:29 am

avatar
Adviser
------------------------
------------------------

Posts : 379
Join date : 2009-07-30
Location : India

http://seleniumforum.forumotion.net

Back to top Go down

Re: Retrieving number of rows in a table

Post by mkunda on 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

mkunda

Posts : 4
Join date : 2010-03-21

Back to top Go down

Re: Retrieving number of rows in a table

Post by Adviser on 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:
http://seleniumforum.forumotion.net/selenium-rc-discussion-f4/can-t-make-rc-code-to-run-t165.htm
avatar
Adviser
------------------------
------------------------

Posts : 379
Join date : 2009-07-30
Location : India

http://seleniumforum.forumotion.net

Back to top Go down

Re: Retrieving number of rows in a table

Post by mkunda on 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 .

mkunda

Posts : 4
Join date : 2010-03-21

Back to top Go down

Re: Retrieving number of rows in a table

Post by metman on 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.

metman
Amateur
Amateur

Posts : 58
Join date : 2010-04-02

Back to top Go down

Re: Retrieving number of rows in a table

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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