未初始化的常量与siteprism

时间:2017-04-23 22:34:22

标签: ruby cucumber

我收到以下错误消息

uninitialized constant PageObjects::Sections::HomePage::SitePrism (NameError) /Users/fee/Desktop/Shafiq/audiobook-collection-manager-acceptance/features/page_objects/sections/home_page/navigation_bar.rb:4:in <module:HomePage> /Users/fee/Desktop/Shafiq/audiobook-collection-manager-acceptance/features/page_objects/sections/home_page/navigation_bar.rb:3:in <module:Sections> /Users/fee/Desktop/Shafiq/audiobook-collection-manager-acceptance/features/page_objects/sections/home_page/navigation_bar.rb:2:in <module:PageObjects> /Users/fee/Desktop/Shafiq/audiobook-collection-manager-acceptance/features/page_objects/sections/home_page/navigation_bar.rb:1:in <top (required)> /Users/fee/Desktop/Shafiq/audiobook-collection-manager-acceptance/features/page_objects/home_page.rb:1:in require_relative /Users/fee/Desktop/Shafiq/audiobook-collection-manager-acceptance/features/page_objects/home_page.rb:1:in <top (required)>

这也是它相关的代码:

require_relative'sections / home_page / navigation_bar'

module PageObjects class HomePage < SitePrism::Page section :navigation_bar, PageObjects::Sections::HomePage::NavigationBar, '.nav-sprite-v1 nav-bluebeacon' end end

module PageObjects module Sections module HomePage class NavigationBar < SitePrism::Section element :your_acc_btn, '.nav-a nav-a-2' end end end end

我在查找导航栏类时遇到问题,但我不确定我哪里出错了可以请有人帮忙。

This is my folder structure

1 个答案:

答案 0 :(得分:0)

require 'site_prism'或更早版本之前

require_relative

通常缺少常量错误可能会非常混乱,因为它们将从被调用的位置显示模块查找。不是您键入SitePrism::Page

的名称

常量查找错误消息的示例。

class Party
  def self.now
    Hard
  end
end

Party.now # => NameError: uninitialized constant Party::Hard

请注意,显示的错误消息确实引用了常量查找的第一层,而不是我们可能想要的根常量。