Search code examples
rubycucumberpage-object-gem

Ruby each.with_index(1) returns error: no block given (yield)


Trying to iterate table rows, skipping the first row. Using Ruby, Cucumber and Page-object gem.

PAGE_CLASS

  table(:table_data, id: 'list')

STEP DEFINITION

@current_page.table_data_element.each.with_index(1) do |row|
  puts row.value
end

getting error message: LocalJumpError: no block given (yield)


Solution

  • This code worked for me.

       @current_page.table_data_element.each do |row|
          if row.text == ''
            next
          else
            row.link_element(text: 'Edit').visible?
          end
        end