Il problema è - non è possibile modificare la finestra di dialogo "Salva con nome ..." tramite goniometro/selenio. Dovresti evitare che venga aperto in primo luogo e lasciare che firefox scarichi automaticamente i file di uno specifico tipo-mime - nel tuo caso application/zip
.
In altre parole, è necessario accendere Firefox con un costume Firefox Profile impostazione del appropriate preferences:
var q = require("q");
var FirefoxProfile = require("firefox-profile");
var makeFirefoxProfile = function(preferenceMap, specs) {
var deferred = q.defer();
var firefoxProfile = new FirefoxProfile();
for (var key in preferenceMap) {
firefoxProfile.setPreference(key, preferenceMap[key]);
}
firefoxProfile.encoded(function (encodedProfile) {
var capabilities = {
browserName: "firefox",
firefox_profile: encodedProfile,
specs: specs
};
deferred.resolve(capabilities);
});
return deferred.promise;
};
exports.config = {
getMultiCapabilities: function() {
return q.all([
makeFirefoxProfile(
{
"browser.download.folderList": 2,
"browser.download.dir": "/path/to/save/downloads",
"browser.helperApps.neverAsk.saveToDisk": "application/zip"
},
["specs/*.spec.js"]
)
]);
},
// ...
}
Qui stiamo praticamente dicendo: Firefox, si prega di scaricare i file zip automaticamente, senza chiedere nella directory /path/to/save/downloads
.
Grazie mille Ha funzionato. –
@alecxe come possiamo verificare che il file venga scaricato? – Nick
@Assicurarsi, attendere che venga scaricato, ecco l'esempio funzionante: http://stackoverflow.com/questions/41082777/protractor-test-download-file-without-knowing-filename. – alecxe