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

  • Home
  • SEARCH
  • 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 9113101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:53:32+00:00 2026-06-17T03:53:32+00:00

Trying to do a dynamic test suite and re-use function definitions. I have a

  • 0

Trying to do a dynamic test suite and re-use function definitions. I have a form where you can pick different types of ways that someone can contact you, and the page will display differently based on the method of contact. I am trying to do

When /^I click the (.*) return type$/ do |response|
  on_page(ContactUsPage).response unless @browser.url.include?("contactBy=#{response}")

This will take the current type of response and click the link unless the url includes “contactBy=” and the response type (meaning you’re already on the page and there is no link to click)

I have a page object class (ContactUsPage) that has links for the different methods (email, phone, fax, postal)

the problem i’m having is with the ContactUsPage.response response is getting injected into the browser check, but it’s looking for a method “response” inside ContactUsPage instead of injecting the method.

The method should call ContactUsPage.email or ContactUsPage.fax or ContactUsPage.phone depending on the method passed into the function.

  • 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-17T03:53:33+00:00Added an answer on June 17, 2026 at 3:53 am

    You can use Ruby’s send method to invoke a method dynamically:

    on_page(ContactUsPage).send(response)
    

    send‘s first argument is a string or symbol with the method name to be invoked; any further arguments are passed to the method itself. For example, foo.send(:bar, "baz") is equivalent to foo.bar("baz")

    If you want to call a method that starts with the variable name (email_element or similar), you just need to do a quick string interpolation:

    on_page(ContactUsPage).send("#{response}_element")
    # equivalent to `on_page(ContactUsPage).email_element` when response == "email"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to target some dynamic form variables using jquery. Only problem is that
I have a method that returns MvcHtmlString, so in my unit test I'm trying
I'm trying to create a C++ dynamic library that won't have a class. I'd
I'm trying to test dynamic id's with PHPUnit so i choose to use xpath
I have some Roo-generated entities, with dynamic finders. I'm trying to unit test a
I am trying to make a form with some dynamic behavior. Specifically, I have
In my test case I am trying to capture the dynamic state id from
I trying to emit dynamic method that sets fields of class by some values
I'm trying to make dynamic menu using xml data, I'm creating that menu using
I am trying to achieve dynamic META information so that it will allow META

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.