Вы знаете, как получить имя типа входного типа из Behat/Mink/Element/NodeElement?Behat/Mink retrieve тип входного файла имя файла
У меня есть простой тест HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<form method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file"/><br/>
</form>
</body>
</html>
Предполагая, что я придаю файл с именем goodCoverArt.jpg, я могу получить это имя файла с помощью следующей команды из хромированной консоли:
$x('//input[@type="file"]')[0].files[0].name
"goodCoverArt.jpg"
Но если я использую следующую функцию в контексте класса:
// Search for that file name label in the page to confirm the execution of the file attachment.
$uploadElement = $this->getElementWhenVisible('xpath', "//div[@id='filename' and contains(.,'$fileName')]");
/**
* @param string $selector xpath|css|...
* @param string $locator link id, title, text or image alt
* @param int $tries
*
* @return NodeElement|mixed|null $element
*/
public function getElementWhenVisible($selector, $locator, $tries = 100)
{
$element = null;
$this->spin(
function() use ($selector, $locator, &$element) {
$element = $this->find($selector, $locator);
if(!($element instanceof NodeElement) || !$element->isVisible())
{
throw new Exception("Element not visible: $selector $locator");
}
}, $tries);
return $element;
}
Как получить такую же информацию от $ uploadElement?