在运行一些Ruby / Cucumber代码时,我遇到了一个奇怪的错误。
运行此代码时:
def navigate_to_expense(expense)
on_page(HomePage).click_top_tab('Expenses')
on_page(HomePage) do |page|
recent = "Expense: #{expense.description}"
if page.recent_items.any? { |i| i[recent] }
page.click_recent_item(recent)
else
on_page(ExpenseSearchPage) do |page|
page.advanced_search
page.search_my_expense(expense)
page.open_search_result(expense)
end
end
end
end
和#click_top_tab:
def click_top_tab(name)
if element_exists?(top_tab_link(name))
top_tab_link(name).click
click_top_tab(name) unless on_tab?(name)
else
link_element(id: 'LINK_menu_services').hover
div_element(class: 'quciklinkdropdiv_globaldirectory', id: 'dropmenu1').link_element(text: name).click
end
end
我遇到以下错误:
When I edit the expense # features/step_definitions/expense_steps.rb:156
undefined method `wait_for_present' for #<Watir::Browser:0x42d7940> (NoMethodError)
./features/support/env.src/team_connect_page.rb:37:in `click_top_tab'
./features/step_definitions/expense_steps.rb:100:in `navigate_to_expense'
./features/step_definitions/expense_steps.rb:157:in `/^I edit the expense$/'
features/scenarios/expenses.feature:16:in `When I edit the expense'
第37行是link_element(id: 'LINK_menu_services').hover
行。如您所见,代码中没有.wait_until_present
,因此我假设错误位于底层页面对象代码中。如果是这种情况,我就无法在已知错误中找到它。如果是我的代码,我对它的位置完全感到困惑?
答案 0 :(得分:0)
由于我无法看到您的整个项目,我无法肯定地说这一点,但是看起来错误发生在homeize内部或继承的类中的initialize_page内。我会看那里。
这只是一个猜测,但看起来有人尝试修复竞争条件并意外地输入wait_for_present而不是wait_ 直到 _present。