【问题标题】:Simulate add element Sonata with Behat用 Behat 模拟添加元素奏鸣曲
【发布时间】:2018-04-04 21:42:49
【问题描述】:

我正在使用奏鸣曲管理包来管理我们的课程,并且我正在使用 behat 创建测试以确保一切正常。

但问题是,当我尝试使用 behat 添加新元素时,出现此错误:

When I visit the advertisement admin page
And I follow "Add new"
And I fill in "Url" with "http://www.example.com"
And I fill in "Video Source" with "http://www.youtube.com"
And I fill in "Text" with "Test new"
And I press "Create and return to list"

The selected node does not have a form ancestor.

问题是因为这个按钮不在表单中,但这是由奏鸣曲管理员管理的。

那么有什么方法可以点击这个按钮而不出现这个错误?

【问题讨论】:

  • 如果可能,请添加您遇到的错误的堆栈跟踪和按钮的 html sn-p。

标签: admin behat sonata mink


【解决方案1】:

奏鸣曲的问题是我在表单中有这个元素,似乎创建了一个不正确的表单:

->add('image', 'sonata_type_model_autocomplete', ['required' => false, 'property' => 'name']);

我换了这个,现在正在工作:

 ->add('image', 'sonata_type_model_list', ['required' => false]);

【讨论】:

  • 你可以删除这个因为不是答案,如果你需要添加更多信息,建议编辑你的问题。
  • 但这是一个答案,我的意思是这就是我解决这个问题的方法,并且可能对其他人有用
  • 是的,但我必须等待两天才能将问题标记为已解决。谢谢!
猜你喜欢
  • 2019-05-22
  • 2017-08-09
  • 2019-05-17
  • 1970-01-01
  • 1970-01-01
  • 2013-07-03
  • 2017-04-27
  • 2013-12-04
  • 2015-03-20
相关资源
最近更新 更多