Behat Framework (Mink Extension)을 사용하여 "파일"유형의 입력 필드에 CSV 파일을 첨부하고 싶습니다.Behat Mink 확장 프레임 워크를 사용하여 입력 필드에 파일 (csv 파일)을 첨부 할 수 없습니다.
입력 필드 ---- 입력 ID = "편집 - ab를 - csv 파일"class = "form-file"type = "file"size = "60"name = "files [ab_csv_file]">
첫번째 방법 우리는
/**
* Attaches file to field with specified id|name|label|value.
*
* @When /^(?:|I)attach the file "(?P<path>[^"]*)" to "(?P<field>(?:[^"]|\\")*)"$/
*/
public function attachFileToField($field, $path)
{
$field = $this->fixStepArgument($field);
if ($this->getMinkParameter('files_path')) {
$fullPath = rtrim(realpath($this->getMinkParameter('files_path')), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$path;
if (is_file($fullPath)) {
$path = $fullPath;
}
}
$this->getSession()->getPage()->attachFileToField($field, $path);
}
}
두번째 방법은 - 우리 내가
말하는 예외를 가지고 자바 스크립트를$jscript = "document.getElementById('edit-ab-csv-file').value='//home//developer//build//tools//behat//Invaliduploadfile.csv';";
$this->getSession()->getDriver()->executeScript($jscript);
를 사용하려고 내가 Driverinterface에 attachfile() 메소드를 사용하여 시도 시도
The operation is insecure. (WARNING: The server did not provide any stack trace information)
Command duration or timeout: 10 milliseconds
누구든지이 문제를 해결할 수 있도록 도와주세요.
:
확장 대신, 당신은 당신 YAML 설정 파일에 "다 (file_paths)"속성을 제공 할 수 있습니다 어디에서 테스트를 실행하는지. 예 :'files_path : % paths.base %/app/Test/Behat/Files' – DanielM
Behat 2에서는 Daniel이 제안한 것에'% behat.paths.base % '를 사용할 수 있습니다. – Greg