25 Mrz

Selenium IDE – How to verify html-table

From time to time every programmer creates a table which looks like this:

test page in browser

Please take notice, the total quantity and the sum look strange. They have to be verified.

The table is simply a set of rows. Look at source code:

source of test page


I’m going to sum the values from the second cell for each row and compare the calculated value with the total quantity. The same should be done with the values of the third cell to get the total amount.

In order to do that, I store the value of the second cell into a global variable ‘quantity’ in Selenium IDE

It works, but I need the value of the second cell of each rows. For this we need to loop through the lines:

Why does the increment of the index look so strange: new Number(${index} + 1) ?

Because normally “+” concatenates strings.

We get the quantity of each row now and they should sum into a different variable.

At first I define the global variable ‘totalQuantity’:

and then I sum all quantities into it in the loop:

Now I have the total quantity at the end. The same way I get the total amount into the variable ‘totalPrice’.

But there is another small problem in cells containing the price: the price has the euro sign before and the text after the price value. In order to use the value we need to get rid of all excessive characters. We can remove it as following:


and convert a decimal separator into ‘.’ then:


Finally the complete script is there:

selenium ide

And, as expected, it reports an error: the total quantity must be 4 though we show 5 in the table.

Share this

Leave a reply