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?
- When exactly are these methods created i.e., when does the page-object class uses
define_method
to implement these methods?
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
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