Php 格式不正确的字段路径“&引用;(无效辩论例外)
我正在使用Behat做一些自动化测试,我已经添加了带有痛风驱动程序的水貂。 我正在使用Behat和Mink的最新版本 我已将Mink扩展名添加到功能上下文文件中,当我运行一个简单的功能时,它会工作,如:Php 格式不正确的字段路径“&引用;(无效辩论例外),php,behat,automated-tests,mink,goutte,Php,Behat,Automated Tests,Mink,Goutte,我正在使用Behat做一些自动化测试,我已经添加了带有痛风驱动程序的水貂。 我正在使用Behat和Mink的最新版本 我已将Mink扩展名添加到功能上下文文件中,当我运行一个简单的功能时,它会工作,如: Feature:... Scenario: See A Blog Post Given I am on the homepage And I follow "login" Then I should be on "/login" And I should se
Feature:...
Scenario: See A Blog Post
Given I am on the homepage
And I follow "login"
Then I should be on "/login"
And I should see "Login"
但是,当我尝试下一步并尝试填写某些字段时:
And I fill in "username" with "admin"
其中用户名:
我得到以下错误:
Malformed field path "" (InvalidArgumentException)
任何帮助都将不胜感激
谢谢 这是因为您的字段上没有
name=“username”
属性。我有一个类似的问题,但我正在尝试测试一个不能有name属性的Stripe实例。看来id
和title
不起作用。勾选的答案为我解决了这个问题
我还发现您可以使用以下语法填写表单:
When I fill in the following:
| username | admin |
| email | myemail@domain.com |
| password | 5uP3r5ecUr3P4s5w0rD|
我还创建了一个自定义FeatureContext函数来帮助查找其他元素:
protected function findElementBySelector($selector)
{
$page = $this->getSession()->getPage();
$element = $page->find('css', $selector);
if (null === $element) {
throw new \Exception(
sprintf('Element with %s not found.', $selector));
}
return $element;
}
其他人使用此函数查找元素并对其执行操作:
/**
* @Then I click the element :selector
*/
public function iClickTheElement($selector)
{
$link = $this->findElementBySelector($selector);
$link->click();
}
我在我的功能中使用了这个。如下所示:
And I ...
And I click the element ".my-link"
Then I ...
其中.my link=
下面的链接有助于创建自定义FeatureContext函数:
您是否已修复此问题?解决办法是什么?刚遇到这个问题时遇到了同样的问题。你找到解决方法了吗?