[英]Ruby uninitialized constant BaseHelper (NameError)
Hi I am having a problem which is driving me mad, When my code complies I receive the error 嗨,我遇到一个让我生气的问题,当我的代码符合要求时,我收到了错误消息
uninitialized constant BaseHelper (NameError)
My code had been working completely fine, up until the point where I added another subclass (AccessoriesMerchandise) my classes look like this 我的代码一直运行良好,直到我添加另一个子类(AccessoriesMerchandise)为止,我的类看起来像这样
BaseHelper class: BaseHelper类:
class BaseHelper
def find(locator)
@browser.find_element locator
end
def type(locator, input)
find(locator).send_keys input
end
end
Child class: 子班:
class FindADealerPage < BaseHelper
#PageObjects
FIND_A_DEALER_SEARCH_FIELD = {id: "abcd"}
MAP_TAB = {css: 'abcd abcd abcd'}
SERVICE_CHECK_BOX = {class: "abcd"}
SUBMIT_SEARCH = {class: "abcd"}
DEALER_RESULTS_FIRST_DEALER = {css: "abcd"}
def initialize(browser, wait)
@browser = browser
@wait = wait
end
def go_to_find_a_dealer_page
@browser.get $base_url
end
end
They are both sitting in the same folder! 他们两个都坐在同一个文件夹中! I added this class where my problems started.
我在出现问题的地方添加了此类。
class AccessoriesMerchandise < BaseHelper
#PageObjects
ACCESSORIES_ACCORDION = {css: 'div.mesSpecAccordion.accessoriesAccordion'}
PANEL_CLOSED = {css: 'h2.trigger'}
PANEL_OPENED_ACTIVE = {css: 'h2.trigger.active'}
def initialize(browser, wait)
@browser = browser
@wait = wait
end
def go_to_page
@browser.get $base_url
end
end
This class is also sitting in the same folder. 此类也位于同一文件夹中。 The framework I am using is, Ruby Selenium WebDriver, Cucumber and Rspec Expectations
我使用的框架是Ruby Selenium WebDriver,Cucumber和Rspec Expectations
You need to require
it 你需要
require
它
It should be something like [As you told both are in same folder] 它应该类似于[正如您所说的,两者都在同一文件夹中]
require 'base_helper.rb'
class FindADealerPage < BaseHelper
#PageObjects
FIND_A_DEALER_SEARCH_FIELD = {id: "abcd"}
MAP_TAB = {css: 'abcd abcd abcd'}
SERVICE_CHECK_BOX = {class: "abcd"}
SUBMIT_SEARCH = {class: "abcd"}
DEALER_RESULTS_FIRST_DEALER = {css: "abcd"}
def initialize(browser, wait)
@browser = browser
@wait = wait
end
...
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.