使用Cucumber和Netzke在Grid Panel中调用一个动作

时间:2012-03-02 08:35:19

标签: cucumber netzke

我正在使用Netzke(0.7.3)开发Rails(3.1.3)。

我对Cucumber很新。

add_account_for_user.feature

Feature: Add Account For User Feature
In order to add login account
As an Administrator
I want to add login account for other role

Scenario: Adding Login Account
  When I login as an Administrator
  Then I should be on admin page

  When I click on 'Administration' button at right upper of page
  Then I should see 'Administrator Management'
  And I should see 'Add' button in Administrator Management toolbar

  When I click on 'Add' button
  Then I wait 10 seconds # for check what happen

问题出在When I click on 'Add' button步。 它通过但不能正常工作。 (它应该触发事件onAddInForm) 它挂在装载中,不显示新的Windows面板。

my_steps.rb

Then /^(?:|I )click on '(\w*)'(?:|.*)$/ do |label|
  click_link_or_button(label)
  step "wait for the response from sever"
end

When /^(?:|I )wait for (?:.*)$/ do
  page.driver.browser.execute_script(<<-JS)
  JS
end

1 个答案:

答案 0 :(得分:0)

找到解决方案!!

解决方案是尝试收集您使用的Component。然后直接调用该动作。

When /I press 'Add' button in the '(\w*)' grid$/ do |grid_name|
  page.driver.browser.execute_script <<-JS
    var containerComp = Ext.getCmp("main_container");   
    var grid = containerComp.down("#"+"#{grid_name.underscore}_grid");
    grid.onAddInForm();
  JS
end

但我仍然不明白为什么在点击后不会拨打onAddInForm