NoMethodError: undefined method `error_div_element'

30 views
Skip to first unread message

mark lane

unread,
Jan 3, 2018, 1:46:36 PM1/3/18
to Cucumber and Cheese
Hi 

I am getting an undefined method error when calling an error handling module and can't work out why. Any help would be greatly appreciated!

My Scenario:
Scenario: Name is a required field
When I checkout leaving the name field blank
Then I should see the error message "Name can't be blank"


My Test Steps:
When(/^I checkout leaving the name field blank$/) do
on(HomePage).select_puppy
on(DetailsPage).add_to_cart
on(ShoppingCartPage).proceed_to_checkout
on(CheckoutPage).checkout('name' => '')
end

Then(/^I should see the error message "([^"]*)"$/) do |msg|
expect(@current_page.error.messages).to include msg
end

My Page Object:
require_relative 'error_panel'

class CheckoutPage

include PageObject
include DataMagic


page_section(:error, ErrorPanel, id: 'error_explanation')
text_field(:name, id: "order_name")
text_area(:address, id: "order_address")
text_field(:email, id: "order_email")
select_list(:pay_type, id: "order_pay_type")
button(:place_order, value: "Place Order")


def checkout(data = {})
populate_page_with data_for(:checkout_page, data)
place_order
end

end

My Module:
class ErrorPanel
include PageObject

unordered_list(:messages) do |page|
page.error_div_element.unordered_list_element
end
end


The error when run:
NoMethodError: undefined method `error_div_element' for #<Watir::HTMLElement: located: false; {:id=>"error_explanation"}>
./features/support/pages/error_panel.rb:5:in `block in <class:ErrorPanel>'
./features/step_definitions/adopting_puppy_steps.rb:87:in `/^I should see the error message "([^"]*)"$/'
./features/adopting_puppies.feature:73:in `Then I should see the error message "Name can't be blank"'




Reply all
Reply to author
Forward
0 new messages