Unit testing Symfony2功能测试错误,带有selectButton功能

Unit testing Symfony2功能测试错误,带有selectButton功能,unit-testing,symfony,phpunit,Unit Testing,Symfony,Phpunit,我在Symfony2上的功能测试中出现“InvalidArgumentException:当前节点列表为空”错误 据我所知,我编写了以下代码: 在测试类中: $client = static::createClient(); $crawler = $client->request('GET', 'http://localhost/site/web/app_dev.php/en/offer'); $buttonCrawlerNode = $crawler->selectButton('

我在Symfony2上的功能测试中出现“InvalidArgumentException:当前节点列表为空”错误

据我所知,我编写了以下代码:

在测试类中:

$client = static::createClient();
$crawler = $client->request('GET', 'http://localhost/site/web/app_dev.php/en/offer');
$buttonCrawlerNode = $crawler->selectButton('SUBMIT');
$form = $buttonCrawlerNode->form();
$form['travelComment'] = 'Hey there!';
在树枝上:

<form method="post" {{ form_enctype(form) }}>
    {{ form_widget(form) }}
    <input value="SUBMIT" type="submit" class="btn btn-primary" />     
</form>

请从您的计算机查看页面的源代码,添加呈现的HTML代码。仔细查看您链接的问题:您是否忘记了表单的名称,例如
表单[travelComment]
?尝试添加
name=“SUBMIT”
,您解决了吗?尝试调查生成的html的结构:如果您的html无效,即未使用的标记,爬虫程序将无法正常工作。希望这对你有所帮助。我使用name=“SUBMIT”进行了尝试,但没有结果。我仍然有同样的信息。呈现的HTML代码似乎很好:
。我将查找未闭合的标签。
InvalidArgumentException: The current node list is empty.