Unable to get table rows in Firefox

Hello everybody,

I have an issue with finding table rows (or cells) in Firefox browser (60.1.0esr). Same test in IE11 works fine.

TestObject Table = ObjectRepository.findTestObject(’…’)
WebElement objTable = WebUiBuiltInKeywords.findWebElement(Table)
// To locate header rows of table it will Capture all the rows available in the table head
List rows_tablehead = objTable.findElements(By.xpath("./thead/tr"))
// To locate rows of table it will Capture all the rows available in the table body, i.e. no header rows
List rows_tablebody = objTable.findElements(By.xpath("./tbody/tr"))

Here we go:
rows_tablehead works in both IE11 and Firefox (List of size 1)
rows_tablebody works in IE11 (size=10), but not in Firefox (size=0)

Consequently I am able to get text for all column headers
List Columns_header = rows_tablehead.get(0).findElements(By.tagName(‘th’))

But never any cells of the table body
int row = 1
List Columns_body = rows_tablebody.get(row).findElements(By.tagName(‘td’))

throws Index out of range, because there are no rows…

The HTML looks like this:

... ....
column 1 column 2 column n
cell text cell text cell text

Does anybody have an idea what I can do to make this work? I also tried different xpath and objTable.findElements(By.tagName(‘td’)) (which gives 0 cells in FF).


do you get some exception? Or there are just 0 results in FF?

Can you compare HTML source code captured in FF with another one captured in IE? Are they the same?

Well up to the final line of code there is no exception.
List Columns_body = rows_tablebody.get(0).findElements(By.tagName(‘td’))

This of course gives an exception, because the list is empty.
Test Cases/Entwicklung/Tabellen FAILED.
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java_util_List$get$0.call(Unknown Source)
at Tabellen.run(Tabellen:136)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:336)

The HTML source code is iedentical in IE11 and Firefox (contains only Javascript of course).
Inspecting the HTML via DOM Explorer in IE1 or Firefox looks also the same.

See attached HTML code:
HTML_Code.txt (797 Bytes)


did you tried to get cell value with Chrome?
which FF version you are using?


If this were me, I’d stop using xpath and stop testing browsers (that’s someone else’s job).

Instead, use CSS selectors. Use what the web is built on. HTML/CSS/JS.

I’ll shut up now. :stuck_out_tongue:

You can try to evaluate your XPath in Firefox - open dev tools, console and put the expression


Does it return correct element?

I have no possibility to install Chrome due to restrictions of my company. FF version is 60.1.0esr (32-Bit).
Obviously I also have no possibility to try an updated FF
I tried “List rows_tablebody = objTable.findElements(By.cssSelector(”.table > tbody > tr"))"
This works in IE11 just like xpath :wink: but it doesn’t work in Firefox: returns an empty list.


latest stable secure FF version is 66.0.5 why your company will use vulnerable FF version.
is this Linux, Mac or Win env?

This is Win environment. My company uses ESR Release of Firefox. Latest version there is 60.6.3 ESR.
That is only a minor update from our current version, however I will try to convince them to do the update.

Evaluation of XPath in Firefox works fine:
That actually gives the expected array of table (data) rows.

Finally the problem is solved. Thanks for all your input - I learned quit a lot.

However I am a bit annoyed with myself, cause it turns out to be a simple synchronization problem. I used
on loading the page.

However for some reason this does not wait until the table is populated - therefore I only got the header row (which is there immediately after loading the page), but never the data rows.
Now I just have to find a more sophisticated way to synchronize the table.