Php 为什么Behat\Mink\Element\NodeElement:setValue会从传递的值中删除破折号?

Php 为什么Behat\Mink\Element\NodeElement:setValue会从传递的值中删除破折号?,php,html,selenium,phantomjs,behat,Php,Html,Selenium,Phantomjs,Behat,我正在使用Behat:3.0.15和Selenium3.4以及PhantomJS作为浏览器 我有自定义步骤来填充输入日期字段的值。基本上只有一行: $element->setValue('1999-01-01'); 我注意到在下一个场景步骤中,结果值为19990101,我的字段未通过验证 因为setValue不只是在字段中“设置值” 如果查看Selenium2Driver中setValue函数的实现,您会发现输入的实际值在以下代码中定义: if (in_array($elementNam

我正在使用Behat:
3.0.15
和Selenium
3.4
以及PhantomJS作为浏览器

我有自定义步骤来填充输入日期字段的值。基本上只有一行:

$element->setValue('1999-01-01');
我注意到在下一个场景步骤中,结果值为19990101,我的字段未通过验证

因为
setValue
不只是在字段中“设置值” 如果查看
Selenium2Driver
setValue
函数的实现,您会发现输入的实际值在以下代码中定义:

if (in_array($elementName, array('input', 'textarea'))) {
    $existingValueLength = strlen($element->attribute('value'));
        // Add the TAB key to ensure we unfocus the field as browsers are triggering the change event only
        // after leaving the field.
    $value = str_repeat(Key::BACKSPACE . Key::DELETE, $existingValueLength) . $value . Key::TAB;
}

因此,如果您对字段中的键盘输入有一些JS处理,
setValue
可能会产生奇怪的结果。

有一个日期选择器用于设置此值。使用javascript填充字段值是可行的,验证也可以。奇怪的