과 비교하십시오. 사용자가 파일을 업로드하는 시스템을 구축 중입니다. Protractor로 파일 업로드를 테스트했지만 이제는 서버에서 원시 파일을 요청할 때 응답이 업로드 된 파일과 동일하다는 것을 확인해야합니다.각도기를 클릭하고 서버 응답을 파일
사용자가 링크를 클릭하여 파일을 다운로드하면 파일에 대한 일반적인 GET 요청이 트리거됩니다. 일반 텍스트 파일을 다루므로 다운로드 한 파일은 첨부 파일로 제공되지 않고 대신 브라우저에 표시됩니다. 관련 PHP 코드는 다음과 같습니다
header('Content-Type: text/plain');
header('Content-Length: ' . $file->getSize());
header('Content-Disposition: filename="file.txt"');
$file->openFile('rb')->fpassthru();
나는 두 가지 문제를 가지고 :
- 어떻게 전체 파일이 다운로드 될 때까지 내가 각도기 대기해야합니까?
- 다운로드 한 파일을 업로드 한 것과 어떻게 비교합니까?
는 여기에 지금까지 가지고있는 작업은 다음과 같습니다
var path = require('path');
function uploadFile(filename) {
var absolutPath = path.resolve(__dirname, filename);
$('input#fileupload').sendKeys(absolutPath);
}
describe('Download', function() {
it('should be exactly the same as an uploaded text file', function() {
uploadFile('data/2.txt');
browser.wait(function() {
return element(by.id('download-button')).isPresent();
});
element(by.id('download-button')).click();
// Wait until page is loaded
// Compare uploaded file with downloaded file
});
});
당신은 [이 답변] (http://stackoverflow.com/a/27031924/771848)가 도움이 될 수 :
내가 여기,하지만이 시도하지 않은 작동 수있는 몇 가지 코드입니다. – alecxe