我正在使用 Cucumber 和 SitePrism 创建测试自动化。运行cucumber
命令以启动场景时出现错误并出现此错误:
uninitialized constant HomePage::Navbar (NameError)
.../features/page_object/home_page.rb:4:in `<class:HomePage>'
.../features/page_object/home_page.rb:1:in `<top (required)>'
我有 3 个 Ruby 类位于单独的文件中
特征/page_object/home_page.rb
class HomePage < SitePrism::Page
set_url "/"
section :navbar, Navbar, "header"
element :flash_message, ".flash__text"
element :username_link, ".c-nav-list__link.u-fg--yellow"
end
功能/page_object/navbar/main.rb
class Navbar < SitePrism::Section
section :login_section, LoginSection, "#new_user_session"
element :login_button, :xpath, "//a[@id='login_link']"
end
功能/page_object/navbar/login_section.rb
class LoginSection < SitePrism::Section
element :username_field, :xpath, "//input[@id='user_session_username'"
element :password_field, :xpath, "//input[@id='user_session_password'"
element :remember_me_checkbox,
:xpath, "//input[@id='user_session_remember_me']"
element :forgot_password_link, :xpath, "//a[text()='Lupa Password?']"
element :submit_button, :xpath, "//button[@type='submit']"
element :facebook_login_button, :xpath, "//a[@id='fb_login_link']"
element :gplus_login_button, :xpath, "//a[@id='gplus_login_link']"
def login(username, password)
self.username_field.set(username)
self.password_field.set(password)
self.submit_button.click
end
end
需要帮助,以便自动化可以正常运行(没有错误)。有什么解决办法吗?