I am testing an application using Selenium IDE. There is a table with unstable row ordering – which means the elements I need to verify are in different rows on each test run.
I’d like to use text known to be in the first column to find the row; and then verify the other columns in the same row.
The test looks like this:
store || //form/table || tableXpath
store || 3 || initialsRow
verifyTable || ${tableXpath}.${initialsRow}.0 || Initials
verifyTable || ${tableXpath}.${initialsRow}.1 || MJ
verifyTable || ${tableXpath}.${initialsRow}.2 || MH
Instead of hard-coding the “initialsRow” value; is it not possible to find the row index dynamically?
The solution I found was to use the Selenium’s
storeElementIndexcommand. It gets the index of an HTML element relative to its parent.See http://release.seleniumhq.org/selenium-core/1.0.1/reference.html
I changed the test as follows:
The XPath query
//form/table//tr/td[text() = "Initials"]/..finds the ‘tr’ element above the ‘td’ element containing the text “Initials”. Selenium stores the index of this ‘tr’ element relative to whatever its parent element is.