我正在尝试访问中定义的类方法Module
,我可以调用函数,但函数具有页面对象元素,该元素执行一些操作,如单击,我收到以下错误:
undefined method "label_year" for Datefunctions:Class (NoMethodError)
这是我的文件结构:
./lib/calender_util.rb
:
module CalenderUtil
def set_date
Datefunctions.get_calender_year
end
end
class Datefunctions
include PageObject
span(:label_year, :class=> 'ui-datepicker-year')
span(:label_month, :class=> 'ui-datepicker-month')
def self.get_calender_year
return label_year
end
end
./home_page.rb
:
require 'calender_helper.rb'
include CalenderUtil
def setTravelDate date
CalenderUtil.set_date
end
部分env.rb
:
require 'page-object'
require 'page-object/page_factory'
$: << File.dirname(__FILE__)+'/../../lib'
require 'calender_helper.rb'
include CalenderHelper
World PageObject::PageFactory
World CalenderHelper
此外; 我已经多次定义了 include/require,一旦解决了我就会起飞。