我正在尝试将 SitePrism 与我的 ruby/capybara/selenium 测试套件一起使用,并且我继续收到错误,期望元素响应has_<element_name>?
规范的最后一行是失败的原因。它给了我一个错误说:
expected #<PageObjects::Pages::SalesPage:0x00000000066782b0> to respond to 'has_toolbar_title?'
sales_page.rb
module PageObjects
module Pages
class SalesPage < SitePrism::Page
set_url "REDACTED"
section :toolbar, PageObjects::Sections::Toolbar, '#qHybridViewToolbar'
end
end
end
工具栏.rb
module PageObjects
module Sections
class Toolbar < SitePrism::Section
element :new_button, '#ToolBtnNew'
element :edit_button, '#ToolBtnUpdate'
element :delete_button, '#ToolBtnDelete'
element :toolbar_title, '#qToolbarViewTitle'
end
end
end
my_spec.rb
require 'spec_helper'
describe 'On sales page' do
context 'without a password' do
it "does the things" do
sales_page = PageObjects::Pages::SalesPage.new
sales_page.load
expect(sales_page).to have_toolbar
sales_page.toolbar.new_button.click
puts sales_page.toolbar.toolbar_title
puts sales_page.toolbar.toolbar_title.text
expect(sales_page).to have_toolbar_title
end
end
end