Maths page


This page will be used to test accessing table data and doing basic maths

The goal is to use the previous examples of geting data from divs, use it to get the :
1. data in the 1st column,
2. the operand in the 2nd column
3. the data in the 3rd column
4. do the calculations
5. compare the result with the data in the 5th column
6. check the = symbol

This is div 1 (id="1stTable")

10
+
10
=
20
# There are 2 ways of getting all the column data
# you would notice that the divs are in a table and the data can
# be accessed via divs or table
1stCell = browser.div(:id, "1stTable").table(:index, 1)[1][1].text
or
1stCell = browser.div(:id, "1stTable").div(:id, "1st").text

2ndCell = browser.div(:id, "1stTable").table(:index, 1)[1][2].text
3rdCell = browser.div(:id, "1stTable").table(:index, 1)[1][3].text
4thCell = browser.div(:id, "1stTable").table(:index, 1)[1][4].text
5thCell = browser.div(:id, "1stTable").table(:index, 1)[1][5].text

# now we can do the calculations, you cant use the symbol directly from the table
# notice that we have to change the text to integer for calculations using .to_i
result = 1stCell.to_i * 3rdCell.to_i

if(result == 5thCell.to_i)
      puts "Answer is correct"
else
      puts "Answer is wrong"
end


This is div 2 (id="2ndTable")

5
-
1
>
3
# same as the example above but different div id


This is div 3 (id="3rdTable")

5
+
1
=
7
# same as the example above but different div id
# Your test should detect that the answer is wrong