What is tags in this code snippet

what is tags in this code snippet?

cell_names = tags(‘UIATableCell’).map { |cell| cell.name }

cell_names.each do |name|
wait { text_exact(name).click }
wait { text_exact name.split(’,’).first }
wait { back }

when i write this throw error-
NoMethodError: undefined method `name’ for #SR:0x007f87fdd82b60

The ‘tags’ method returns an array of elements of the type you specify in the parameter. So this code:

cell_names = tags('UIATableCell').map { |cell| cell.name }

Populates ‘cell_names’ with all of the elements of type, ‘UIATableCell’. This code:

cell_names.each do |name|
  wait { text_exact(name).click }
  wait { text_exact name.split(',').first }
  wait { back }

Iterates through the array and performs operations on each element found.

If there are no elements of type ‘UIATableCell’ then you will have an empty array and will get the error you describe.

thank you wreed

what if I have UIATableCell at this path-

:xpath, “//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell”

How do i modify content of paranthesis in tags-


would this work?


No! Don’t do that.

Xpath and tags use very different strategies for finding elements. You can’t really mix them like that.

However, if there is only one UIATableCell (doubtful, but maybe) you could use:


Which would return one element. But with tags you need to iterate through. Most people on this forum recommend that you only use Xpath as a last result because it’s slow and brittle.

So for the question of how to modify, you’ll need to run tags(‘UIATableCell’) and then iterate to the cell you want to change. I think you could probably click it and then sendkeys with the string value you want to populate the cell.