Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8166299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:48:54+00:00 2026-06-06T19:48:54+00:00

do you happen to know if there is a way to define both elements

  • 0

do you happen to know if there is a way to define both elements and locators using string or symbol interpolation while using the site-prism gem?

I’m trying to do something like this:

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

But I’m getting the following syntax error at executing:

syntax error, unexpected tSYMBEG, expecting keyword_do or ‘{‘ or ‘(‘ (SyntaxError)
element :”adult#{index}” , “#passenger-first-name-#{index}”

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

Maybe I am missing something? Thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:48:57+00:00Added an answer on June 6, 2026 at 7:48 pm

    I haven’t tried symbol interpolation, but the string interpolation should work. But, you many not need to do that… usually, this sort of thing can be solved by more closely modelling your website using sections. Instead of dynamically creating elements, you could use the elements or sections methods that will create arrays of elements. Here’s what I’d do based the example you’ve given:

    I’m guessing from your example that your website lists passengers… if each passenger is displayed in a separate div then you could consider something like:

    #section that models a single passenger
    class PassengerDetails < SitePrism::Section
      element :first_name, "input[id^=passenger-first-name]"
      element :last_name, "input[^=passenger-last-name]"
    end
    
    #page that contains a list of passengers
    class FlightManifest < SitePrism::Page
      sections :passengers, PassengerDetails, ".passenger-details"
      #... where ".passenger-details" is a style on the divs that contains a passenger's details
    end
    

    Given the above, you could refer to the list of passengers as an array:

    Then /^the flight manifest contains the correct first and last names for each passenger$/ do
      @flight_manifest.passengers.each_with_index do |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 that helps, or if it’s possible with your website, but it might point you in the right direction…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone happen to know if there is any difference with regards to performance
I know there's a cleaner way to do this than the way I am.
Would anyone happen to know a trick that will keep this MSBuild task from
Would you happen to know of any tools that can be used to find
In Android, I have a Path object which I happen to know defines a
I would like to know what will happen in the following hypothetical situation. Let's
I want to know that what will happen to my activity incase of an
how to know where is this thing realy happen? my abject are complicate for
Is there a clean way to have a decorator call an instance method on
Hi I am using Joomla and WordPress both and I use a single sign-on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.