Results 1 to 3 of 3

Thread: File Upload

  1. #1

    Default File Upload

    Hello, I'm new to Sencha Test,

    I need to test a file upload.
    The problem is, while running the test, when I click the "Choose File" button the dialog doesn't open and it's not possible to choose a file, and set the value for an input type file isn't allowed.
    I tried to use the Event Recorder and as soon the dialog opens to choose a file it stops recording.

    Is there a way to solve that or is just not possible to make that test ?

    Sencha Test Version: 2.2.0
    Browser: Chrome 70.0.3538.77


  2. #2
    Sencha - Sales Team daniel.gallo's Avatar
    Join Date
    Apr 2009
    Location
    Redwood City, CA
    Posts
    292
    Answers
    40

    Default

    This is possible within a WebDriver scenario. Please see the example below.

    Code:
    // Scenario URL: http://examples.sencha.com/extjs/6.6.0/examples/kitchensink/frame-index.html?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/danielgallo/Documents/TestImage.jpg');
                });
        });
        
        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"]', 10000)  // Allow up to 10 seconds for upload to finish
                .textLike(/File processed on the server/);
        });
    });
    Daniel Gallo
    Senior Solutions Architect
    Sencha Inc.

  3. #3

    Default

    Thank you very much Daniel.

    It worked like a charm

Similar Threads

  1. Replies: 4
    Last Post: 18 Dec 2014, 10:12 PM
  2. How to disable file upload field and file upload icon
    By mypen in forum Ext 3.x: Help & Discussion
    Replies: 11
    Last Post: 18 Feb 2011, 7:45 AM
  3. How to disable file upload field and file upload icon
    By mypen in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 31 Jan 2011, 2:16 AM
  4. How to disable file upload field and file upload icon
    By mypen in forum Sencha Touch 1.x: Discussion
    Replies: 3
    Last Post: 26 Jan 2011, 1:04 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •