I am trying to validate that my form fields all have an associated label using Selenium, but I am having problems grabbing all of the form fields on a page. get_all_fields only gets textfields; I have no way to also grab the passwords, radios, checkboxes, etc.
I was trying something like this:
num_fields = Integer(selenium.get_xpath_count("//input"))
1.upto(num_fields) do |field_number|
input_id = selenium.get_attribute("//input[#{field_number}]@id")
selenium.element?("css=label[for=#{input_id}]")
end
The problem is that //input[1] doesn't work; the inputs are nested in various markup depending on the page.
Is there a way to use a selenium locator to generically grab the first, second, etc input?