ruby - Defining elements and locators with interpolation in site-prism? -


do happen know if there way define both elements , locators using string or symbol interpolation while using site-prism gem?

i'm trying this:

0.upto(@adults)  { element :"adult#{index}", "#passenger-first-name-#{index}" element :"adult#{index}", "#passenger-last-name-#{index}" index+=1 } 

but i'm getting following syntax error @ executing:

syntax error, unexpected tsymbeg, expecting keyword_do or '{' or '(' (syntaxerror) element :"adult#{index}" , "#passenger-first-name-#{index}"

i reading here symbols allow interpolation: http://www.robertsosinski.com/2009/01/11/the-difference-between-ruby-symbols-and-strings/

maybe missing something? lot!

i haven't tried symbol interpolation, string interpolation should work. but, many not need that... usually, sort of thing can solved more closely modelling website using sections. instead of dynamically creating elements, use elements or sections methods create arrays of elements. here's i'd based example you've given:

i'm guessing example website lists passengers... if each passenger displayed in separate div consider like:

#section models single passenger class passengerdetails < siteprism::section   element :first_name, "input[id^=passenger-first-name]"   element :last_name, "input[^=passenger-last-name]" end  #page contains list of passengers class flightmanifest < siteprism::page   sections :passengers, passengerdetails, ".passenger-details"   #... ".passenger-details" style on divs contains passenger's details end 

given above, refer list of passengers array:

then /^the flight manifest contains correct first , last names each passenger$/   @flight_manifest.passengers.each_with_index |passenger, i|     passenger.first_name.text.should == @expected_passengers[i].first_name     passenger.last_name.text.should == @expected_passengers[i].last_name   end end 

i don't know if helps, or if it's possible website, might point in right direction...


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -