Skip to content

Instantly share code, notes, and snippets.

@DanielGallo
Last active June 15, 2021 06:57
Show Gist options
  • Save DanielGallo/4b99445f5a97de9da8d64ab69aa996a3 to your computer and use it in GitHub Desktop.
Save DanielGallo/4b99445f5a97de9da8d64ab69aa996a3 to your computer and use it in GitHub Desktop.
File upload from Sencha Test WebDriver Scenario
// Scenario URL: http://examples.sencha.com/extjs/6.6.0/examples/kitchensink/?classic#form-fileuploads
describe('File Upload', function() {
it('should select a file to upload', function() {
// Populate name field (required)
ST.textField('form[title="File Upload Form"] textfield[fieldLabel="Name"]')
.setValue('My Screenshot');
// Find file upload field's HTML element (the actual HTML file upload field)
ST.element('form[title="File Upload Form"] filefield[name="photo-path"] => input[type="file"]')
.get('id')
.and(function() {
// Use the id of the file input field
var fileFieldId = this.future.data.id;
// Use WebDriver.io API to choose a file (define full file path)
ST.defaultContext.driver.chooseFile('#' + fileFieldId, '/Users/dan/Pictures/Picture1.png');
});
});
it('should upload the file', function() {
// Click the "Save" button, which uploads file to the server
ST.button('form[title="File Upload Form"] button[text="Save"]')
.click();
// Wait for upload confirmation message box to be available
ST.component('messagebox[title="Success"]')
.textLike(/File processed on the server/);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment