page object gem - when are the required methods generated?
NickName:x-treme Ask DateTime:2013-11-11T21:53:53

page object gem - when are the required methods generated?

I believe that when using page-object gem, having a method call like

link(:sym, text: "example.com")

generates three methods - sym, sym_element and sym? Can anybody clear the following doubts?

  1. When exactly are these methods created i.e., when does the page-object class uses define_method to implement these methods?
  2. These method calls (link(:sym, text: "example.com") are present directly inside the class without being wrapped inside another method!! Is it allowed to have statements directly inside a class without being wrapped in a method? If so, what is the use of those statements?

    class Test
      include PageObject
    
      def example_method        
        puts "example method"    
      end
    
      link(:sym, text: "example.com")        
    end
    
  3. Can I call (link(:sym, text: "example.com") inside a method present in my class. Doing it this way throws a NoMethodError!! Is this not allowed?

Copyright Notice:Content Author:「x-treme」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/19908085/page-object-gem-when-are-the-required-methods-generated

More about “page object gem - when are the required methods generated?” related questions

page object gem - when are the required methods generated?

I believe that when using page-object gem, having a method call like link(:sym, text: "example.com") generates three methods - sym, sym_element and sym? Can anybody clear the following doubts? ...

Show Detail

Is there a way to combine page object gem and javascript calls

Im using the page object gem and selenium, when filling in a sign up form, the form fills in correctly, but when clicking apply it errors saying the fields are required even though they are filled...

Show Detail

Page object gem with Bootstrap

I have been using the Ruby page object gem successfully for the last few months, however the new software I'm testing is using Bootstrap so it has become harder. e.g I'm trying to select from a dr...

Show Detail

framework using page Object gem - bundle as a gem

I would like to create a framework using the ruby page object gem. The idea is simple. I want to seperate the common re-uable components under framework project and then finally bundle all these as...

Show Detail

Is it possible to dynamically create a page object element

I am using Cheezy's page-object gem. It works wonderfully in most cases but I can't seem to utilize it when working with dynamically created elements. I have a method for clicking on a cell by pass...

Show Detail

Accessing gem class methods in rails app

I have created my own gem 'mygem'. In the lib directory I have mygem.rb ruby file. This file has 3 methods defined. Now I have created a rails app and I intend to use my gem in this app. In the

Show Detail

Calling a module's methods on a Gem's object?

I've generated an object via a ruby gem (Koala) and I've written a few modules with helper methods. What do I need to do in order to be able to use the methods within the modules on the object? If...

Show Detail

Initializing page objects with page-object-gem

I have a series of test that I have written page objects for. I am attempting to convert them over to use the page-object-gem. page_object_base.rb require_relative '../../selenium_helper' module

Show Detail

How to navigate to a link using page object gem?

How to navigate to a page using page-object gem when am calling in a method? class SidePage include PageObject link(:create, text: /Create/) def navigate_to(link) if link == 'Test' create

Show Detail

Where to place methods from a gem

I'm using the following Acts as message gem for messages. The gem states that to mark a message as read do the following: @message.mark_as_read Below is my code in which I'm iterating over each m...

Show Detail