considering this simple Page Object:
require 'watir-webdriver'
require 'page-object'
class SomePage
include PageObject
text_field :first_name, :name => "fname"
text_field :last_name, :name => "lname"
text_field :birth_date, :name => "birthday"
button :submit, :type => "submit"
end
browser = Watir::Browser.new
page = SomePage.new(browser)
is there a way to iterate over all the text fields (or any elements) to access their "identifier" (i.e. :username, :password or :birth)?
something like:
page.text_fields.each do |text_field|
puts text_field.identifier.inspect
end
=> :first_name
=> :last_name
=> :birth_date
I'm just looking to see if I could turn this:
page.first_name = @user.first_name
page.last_name = @user.last_name
etc...
into this:
page.text_fields.each do |text_field|
attribute = text_field.attribute
text_field = @user[attribute]
end
Anybody knows what I mean?