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 7851403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:10:28+00:00 2026-06-02T19:10:28+00:00

I have a page object called LineItemsPage class LineItemsPage attr_accessor :add_line_item_button def initialize(test_env) @browser

  • 0

I have a page object called LineItemsPage

class LineItemsPage
  attr_accessor :add_line_item_button

  def initialize(test_env)
    @browser              = test_env[:browser]
    @action_bar           = @browser.div(:id => 'lineitems_win').div(:class => 'window-body').div(:class => 'actionbar')
    @add_line_item_button = @action_bar.img(:class => 'button add')
  end

  def method_missing(sym, *args, &block)
    @browser.send sym, *args, &block
  end

end

I use it like so:

When /^I click on Add Item and enter the following values:$/ do |table|
  @line_items_page = LineItemsPage.new(@test_env)
  @line_items_page.add_line_item_button.when_present.click
end

I’m wondering if I should be abstracting the click, by adding something like the following to my LineItemsPage class:

def add_item
  self.add_line_item_button.when_present.click
end

And then using it like so:

@line_items_page.add_item

I’m looking for best practices, either with regards to Page Object in particular or Ruby in general. I feel that encapsulating the interface by using add_item() is going a bit far, but I’m wondering if I’m unaware of issues I might run into down the road if I don’t do that.

  • 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-02T19:10:30+00:00Added an answer on June 2, 2026 at 7:10 pm

    Personally, I try to make my page object methods be in the domain language with no reference to the implementation.

    I used to do something like @line_items_page.add_line_item_button.when_present.click, however it has caused problems in the following scenarios:

    1) The add line item was changed from a button to a link.

    2) The process for adding a line item has changed – say its now done by a right-click or it has become a two step process (like open some dropdown and then click the add line).

    In either case, you would have to locate all the places you add line items and update them. If you had all the logic in the add_item page object method, you would only have to update the one place.

    From an implementation perspective, I have found that Cheezy’s page object accessors work pretty well. However, for image buttons (or any of your app’s custom controls), I would add additional methods to the PageObject::Accessors module. Or if they are one off controls, you can add the methods directly to the specific page object.

    Update – Reply to Comment Regarding Some Starting Points:

    I have not come across too much documentation, but here are a couple links that might help:

    1) The Cheezy Page Object project wiki – Gives a simple example to get started

    2) Cheezy’s blog posts where the page object gem first started. Note that the content here might not be exactly how the gem is currently implemented, but I think it gives a good foundation to understanding what he is trying to achieve. This in turn makes it easier to understand what is happening when you have to open up and modify the gem to fit you needs.

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

Sidebar

Related Questions

I have a parent object called Page that has a List of objects called
I have this class: class View(object): def main_page(self, extra_placeholders = None): file = '/media/Shared/sites/www/subdomains/pypular/static/layout.tmpl'
I have an application that's instantiates an object from a class called SecretNumber when
I have created a class called BasePage which inherits System.Web.UI.Page. On this page I've
I have a scenario where I have a Object called Page, and another object
I have an link in HTML and I use Page Object pattern to write
I have a page based on a model object, and I want to have
I have a page in which I want to maintain the value of object
I have a web page with swf file defined this way <object width=600 height=400
I have an ActiveX object which extends some functions. I have a web page

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.