0
比方說,我有一個表格:Symfony 2爬蟲窗體提交顯示錯誤「LogicException:無法在」輸入「標記上提交。」
<form action="test.php" method="post">
<input type="text" name="myinput" value="3" />
<button>Submit</button>
</form>
這是我的篩選,並與履帶測試:
$client = static::createClient();
$crawler = $client->request('GET', 'test.php');
$filter = 'button';
$buttonNode = $crawler->selectButton($crawler->filter($filter));
$this->assertEquals(1, $buttonNode->count()); // this works
$form = $buttonNode->form(); // This shows error "LogicException: Unable to submit on a "input" tag."
$client->submit($form);
我不能讓Symfony2的TestClient的到提交沒有提交按鈕的表單。你可以使用像selenium,sahi或zombie.js這樣的測試,或者添加一個輸入提交按鈕,然後用css隱藏。 – Sgoettschkes