I am trying to verify that my form fields have an associated label using Selenium, but I am having problems capturing all form fields on the page. get_all_fields gets only text fields; I also have no way to capture passwords, radios, flags, etc.
I tried 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] does not work; inputs are nested in different layouts depending on the page.
Is there a way to use a selenium locator for a common capture of the first, second, etc. input?
source
share