Once a grid has been located, we usually want to see or do something to at least one of the rows in the grid.
This is pretty straightforward in Dojo grids as it is in more or less standard html tables. The header row and the data rows in the Dojo grid are in separate divs, each with a unique class name within the parent div of the grid.
In this example the parent div has id ‘dojox_grid_EnhancedGrid_1’. The div with class ‘dojoxGridContent’ contains the data rows. To select the radio button in the row that contains ‘POC Co-Borrower Two’, we need to remember that a Dojo radio button is actually a division.
First we have to locate the section which contains the target grid and get its index.

section_div = browser.h2(:text, /AFS Results/).parent
target_grid = section.div(:id, /^dojox_grid_.*Grid_d+$/i)
grid_index = target_grid.id.match(/^dojox_grid_.*Grid_(d+)$/i)[1]

Then we locate the element (a span in this example) with the target text and then walk up the parent branch until we get to the row parent and then capture the ‘gridRowIndex’ attribute value ( 1 in this sample).

data_row_div = target_grid.span(:text, ‘POC Co-Borrower Two’)
row_index = ‘’
until (data_row_div.class.include?(‘dojoxGridRow’) do |div|
if data_row_div.attribute_value(‘gridRowIndex’)
row_index = data_row_div.attribute_value(‘gridRowIndex’)
break
end
data_row_div = data_row_div.parent
end

7-29-2013 4-10-11 PM

Another route takes advantage of the webdriver ability to accept multiple locator parameters. We still have to locate the correct grid and capture its index as above. The locator parameters are chosen to get the right level division that contains the target text.

data_row_div = target_grid.div(:class =>/dojoxGridRow/, :text => ‘POC Co-Borrower Two’)
row_index = data_row_div.attribute_value(‘dataRowIndex’)

In both cases, once we have gotten both the grid and row indices we can set the ‘radio’ by clicking the division in the row with the correct id.

radio_id = “dojox_grid_EnhancedGrid_#{grid_index}_rowSelector_#{row_index}”
section_div.div(:id, radio_id).click

How can we make this easier to locate and therefore to automate? A good question. Given the generated Dojo grid structure there may not be a ‘fix’. Even when the tabular data is rendered using an html table containing all of the data rows, the correct table must be located and the correct row within it.