Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a Selenium Junit test, for a table with 'n' rows in a dialog box of a webpage, I am able to calculate number of rows using Table.size() (Table is a List of elements which finds elements with tag tr)

The problem is the size() gives all rows (n rows) in the table. How do I calculate rows which are seen only on the view (having height of 'x'px -I am able to calculate the height of table and rows though ).

share|improve this question
Please post relevant HTML and Java code. – FDM May 11 '15 at 5:16

Hello @rOCkINGsp007 ,

Whenever you're finding elements with tag tr , just check whether the element is visible or not.

If element is visible/displayed then add it an array and at last you can find the total number of elements were displayed in a page from array

share|improve this answer

The height is calculated using getCssValue("height") property. I am not sure if it is the correct way to limit the count or if is there any function which can limit rows?

I am able to use table.size() to get the count of the rows which includes rows in the dialog-box (after scrolling down the dialog) whereas I want rows only screen on top without scrolling.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.