hash has a has_key? method Paul
On Thu, Apr 2, 2009 at 3:30 PM, George <george.sand...@gmail.com> wrote: > > Hello everyone, > > I'm hoping this is the right forum for this question. I'm trying to > iterate through a hash and check certain text fields on a webpage: > > Here is where I'm storing my controls: > > controls.rb # stores the form control variables > =========================== > def tf_company_name > $tf_company_name = $ie.text_field(:id, "CompanyName") > end > > def tf_address > $tf_address = $ie.text_field(:id, "StreetAddress") > end > > def tf_city > $tf_city = $ie.text_field(:id, "City") > end > > Here is where I'm defining the iteration: > > form_checks.rb # Check form controls > =========================== > def check_contact_form_controls > contact_controls = [tf_company_name => "Company Name", > tf_address => "Address", > tf_city => "City"] > contact_controls.each do |key, value| > if key.exists? > puts "PASS: Control #{value} exists." > else > puts "FAIL: Unable to locate control #{value}" > end > end > end > > > Since hashes does not have an exists? method, I get an error. Is > there a better way to do this? > > Thanks, > > George > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~----------~----~----~----~------~----~------~--~---