未初始化常量与 siteprism

uninitialized constant with siteprism

我收到以下错误消息

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

我在定位导航栏时遇到问题class,但我不确定哪里出错了,有人可以帮忙吗?

This is my folder structure

require 'site_prism' 早于 require_relative 或更早。

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

常量查找错误消息示例。

class Party
  def self.now
    Hard
  end
end

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

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