Can not upload a file. DOM elements:
<button type="button" id="button-upload" data-loading-text="Loading..." class="btn btn-primary"><i class="fa fa-upload"></i> Upload</button>
$('#button-upload').on('click', function() {
$('#form-upload').remove();
$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');
$('#form-upload input[name=\'file\']').trigger('click');
if (typeof timer != 'undefined') {
clearInterval(timer);
}
timer = setInterval(function() {
if ($('#form-upload input[name=\'file\']').val() != '') {
clearInterval(timer);
// Reset everything
$('.alert-dismissible').remove();
$('#progress-bar').css('width', '0%');
$('#progress-bar').removeClass('progress-bar-danger progress-bar-success');
$('#progress-text').html('');
$.ajax({
url: 'index.php?route=marketplace/installer/upload&user_token=user_token_here',
type: 'post',
dataType: 'json',
data: new FormData($('#form-upload')[0]),
cache: false,
contentType: false,
processData: false,
beforeSend: function() {
$('#button-upload').button('loading');
},
complete: function() {
$('#button-upload').button('reset');
},
success: function(json) {
if (json['error']) {
$('#progress-bar').addClass('progress-bar-danger');
$('#progress-text').html('<div class="text-danger">' + json['error'] + '</div>');
}
if (json['text']) {
$('#progress-bar').css('width', '20%');
$('#progress-text').html(json['text']);
}
if (json['next']) {
next(json['next'], 1);
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
}, 500);
});
As I think the input appears after click button. But it opens OS dialog. I'd like to send a file without OS dialog. Now I'm using python. But the important thing is to use selenoid or another cluster for concurrent tests.
Please help me to understand how to do it.