我正在测试我的验证,我在所有输入中发送了错误的值:
$crawler = $this->client->getCrawler();
$form = $crawler->selectButton('Créer')->form();
$form->setValues([
'Contractor[lastName]' => str_repeat('maxLength', self::OVER_MAX_LENGTH,),
'Contractor[firstName]' => str_repeat('maxLength', self::OVER_MAX_LENGTH,),
'Contractor[email]' => str_repeat('maxLength', self::OVER_MAX_LENGTH,).'@society.com',
'Contractor[phone]' => str_repeat('0', self::UNDER_MIN_LENGTH,),
'Contractor[password][password][first]' => 'first',
'Contractor[password][password][second]' => 'second',
'Contractor[status]' => 'admin.crud.user.field.choices.boss'
]);
$this->client->submitForm('Créer');
$this->client->waitFor('.invalid-feedback');
$this->client->waitForVisibility('.invalid-feedback');
$this->client->takeScreenshot('add.png');
$totalErrors = $crawler->filter('div.invalid-feedback')->count();
$errorExpected = 5;
$this->assertNotCount($totalErrors, [$errorExpected]);
当我测试时,我要求等到显示错误。然后我计算错误的数量并进行比较。问题是当这条线是测试$totalErrors = $crawler->filter('div.invalid-feedback')->count();
我有一个错误说:
Facebook\WebDriver\Exception\StaleElementReferenceException: stale element reference: element is not attached to the page document
。
在屏幕截图中,显示了错误。
我真的不明白为什么,因为我要求等待元素进入 DOM 并且我没有错误。
任何想法 ?