Tables page
This page will be used to test accessing table data and doing basic maths
This is table 1
10 |
20 |
30 |
40 |
50 |
# This is the table code
<table class="sample" width = "200" border="2" bordercolor=red>
# This is the 1st table in the div; main or div; 1stTable
# to access it:
browser.div(:id, "1stTable").table(:index, 1)
browser.div(:id, "1stTable").table(:class, "sample").text
# To get the 1st value in the table, notice that there
# is a div in each cell so you can refer to the cell via its div
browser.div(:id, "1stTable").table(:index, 1).div(:id, "1st").text
# The aim of this exercise is to show you have to access table elements using arrays
# you can take entire table as an array.
browser.div(:id, "1stTable").table(:index, 1)[1][1].text
# this will give you the text in row 1 column 1 which is 10
browser.div(:id, "1stTable").table(:index, 1)[1][3].text
# this will give you the text in row 1 column 3 which is 30
This is table 2
1 |
2 |
3 |
4 |
5 |
# This is the table code
<table class="sample" width = "200" border="1">
# This is the 2nd table in the div; main
# or the 1st table in div; 1stTable
# to access it:
browser.div(:id, "2ndTable").table(:index, 1)
browser.div(:id, "main").table(:index, 2).text
# To get the 1st value in the table, notice that there
# is a div in each cell so you can refer to the cell via its div
browser.div(:id, "1stTable").table(:index, 1).div(:id, "1st").text
# The aim of this exercise is to show you have to access table elements using arrays
# you can take entire table as an array.
browser.div(:id, "2ndTable").table(:index, 1)[1][1].text
# this will give you the text in row 1 column 1 which is 1
browser.div(:id, "2ndTable").table(:index, 1)[1][3].text
# this will give you the text in row 1 column 3 which is 3
This is table 3
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
# This is the table code
<table class="sample" width = "200" border="1">
# This is the 3rd table in the div; main
# or the 1st table in div; 3rdTable
# to access it:
browser.div(:id, "3rdTable").table(:index, 1)
browser.div(:id, "main").table(:index, 3).text
# To get the 1st value in the table, notice that there
# is a div in each cell so you can refer to the cell via its div
browser.div(:id, "3rdTable").table(:index, 1).div(:id, "1st").text
# The aim of this exercise is to show you have to access table elements using arrays
# you can take entire table as an array.
browser.div(:id, "3rdTable").table(:index, 1)[3][2].text
# this will give you the text in row 3 column 2 which is 12
browser.div(:id, "3rdTable").table(:index, 1)[2][3].text
# this will give you the text in row 2 column 3 which is 8