Q:

How to click on all li elements in menu?

I am trying to click on all links on top menu on site http://watirwebdriver.com/
require 'watir-webdriver'

class Proba
  def test
    b = Watir::Browser.new
    b.goto "watirwebdriver.com"
    b.ul(:id => 'menu-watirwebdriver-menu').lis.each do |li|
      li.click
    end
  end
end

proba = Proba.new
proba.test

But there is a problem raised:
https://gist.github.com/3239338
What could be a problem?

A:

All your li aren't visible. Check if they are.
To click only on visible li, you can do this :
  def test
    b = Watir::Browser.new
    b.goto "watirwebdriver.com"
    b.ul(:id => 'menu-watirwebdriver-menu').lis.each do |li|
      li.click if li.visible?
    end
  end

