• Home (current)
    • About
    • Contact
    • Cookie
    • Home (current)
    • About
    • Contact
    • Cookie
    • Disclaimer
    • Privacy
    • TOS
    Login Or Sign up

    Upload file - Protractor

    1.6k Views Asked by Andurit At 22 June 2015 at 10:16 2025-12-19T09:41:10.954517

    I fight with protractor because for some tests I need to UPLOAD file. My HTML looks like:

    <div class="panel-footer">
        <ul class="list-unstyled">
          <!-- ngRepeat: file in imagesToUpload -->      
        </ul>
        <button class="btn btn-sm btn-success pull-right ng-binding ng-hide" ng-show="imagesToUpload.length" ng-click="uploadImages()">Nahrát na server</button>
        <button class="btn btn-sm btn-primary ng-binding" ng-file-select="onImageSelect($files)" data-multiple="true" style="overflow: hidden;">Vybrat soubory<input type="file" class="btn btn-sm btn-primary ng-binding" ng-file-select="onImageSelect($files)" data-multiple="true" multiple="multiple" __wrapper_for_parent_="true" style="width: 1px; height: 1px; opacity: 0; position: absolute; padding: 0px; margin: 0px; overflow: hidden;"></button>
      </div>
    

    INPUT HTML:

    <input type="file" class="btn btn-sm btn-primary ng-binding" ng-file-select="onImageSelect($files)" data-multiple="true" multiple="multiple" __wrapper_for_parent_="true" style="width: 1px; height: 1px; opacity: 0; position: absolute; padding: 0px; margin: 0px; overflow: hidden;">
    

    I search a lot about this issue in protractor. And basicly people advise was to COPY / PASTE path to file to input and then click "UPLOAD"

    In my case there is a problem becuase input is here but it store some object not PATH

    If I pick file manualy it store in HTML like:

    <li ng-repeat="file in imagesToUpload" class="ng-binding ng-scope">
            FileName.png <span title="remove" class="btn btn-flat glyphicon glyphicon-remove" ng-click="imagesToUpload.splice($index, 1)"></span>
          </li>
    

    Maybe this is really stupid but I am thinking if there isnt some other way how to do this? Maybe create object and send it there or something else?

    Any advice is welcome.

    javascript selenium testing protractor end-to-end
    Original Q&A
    1

    There are 1 best solutions below

    5
    alecxe alecxe On 22 June 2015 at 12:59 BEST ANSWER

    The common and the most realistic way to upload the file via protractor/selenium is to send keys to the file input and avoid opening the upload file dialog which you cannot control:

    var uploadInput = element(by.css("input[type=file]"));
    uploadInput.sendKeys("path/to/file");
    

    Related Questions in JAVASCRIPT

    • Using Puppeteer to scrape a public API only when the data changes
    • inline SVG text (js)
    • An array of images and a for loop display the buttons. How to assign each button to open its own block by name?
    • Storing the preferred font-size in localStorage
    • Simple movie API request not showing up in the console log
    • Authenticate Flask rest API
    • Deploying sveltekit app with gunjs on vercel throws cannot find module './lib/text-encoding'
    • How to request administrator rights?
    • mp4 embedded videos within github pages website not loading
    • Scrimba tutorial was working, suddenly stopped even trying the default
    • In Datatables, start value resets to 0, when column sorting
    • How do I link two models in mongoose?
    • parameter values only being sent to certain columns in google sheet?
    • Run main several times of wasm in browser
    • Variable inside a Variable, not updating

    Related Questions in SELENIUM

    • Can't get Selenium element
    • Trying to find HREF from table with Selenium in Python
    • Python | How i get the link of products that doesn't have href with selenium
    • Selenium works only when I'm connected to a remote server
    • Logging in automation using Selenium requests / responses- why it wont work?
    • Why can't I scrape data from etherscan
    • TypeError: 'SwitchTo' object is not callable
    • Why driver.get doesn't work in Python Selenium when using Profile
    • Trying to fill out an online form using selenium but it can't find the element
    • Targeting Accept Policy With Selenium
    • Python Selenium - Select Options not returning all the options
    • Spraping data from a table is slow but uncertain why
    • Unable to convert byte[] image to base64 using cucumber scenario api's - java selenium
    • Selenium WebDriver - google account login problem using python
    • Click on login button using Selenium

    Related Questions in TESTING

    • Using ES Modules with TS, and Jest testing(cannot use import statement outside module)
    • Mocking AmazonS3 listObjects function in scala
    • How to refer to the filepath of test data in test sourcecode?
    • No tests found for given includes: [com.bright.TwitterAnalog.AuthenticationControllerSpec.Register user with valid request](--tests filter)
    • Error WebMock::NetConnectNotAllowedError in testing with stub using minitest in rails (using Faraday)
    • How to use Mockito for WebClient get call?
    • Jest + JavaScript ES Modules
    • How to configure api http request with load testing
    • How can I make asserts on outbound HTTP requests?
    • higher coefficient of determination values in the testing phase compared to the training phase
    • Writing test methods with shared expensive set-up
    • Slow performance when testing non-local IP services with Playwright
    • uiState not updating in Tests
    • Incorrect implementation of calloc() introduces division by zero and how to detect it via testing?
    • How to test Creating and Cancelling Subscription in ThriveCart in Test Mode

    Related Questions in PROTRACTOR

    • [Protractor]: session not created: This version of ChromeDriver only supports Chrome version 114 Current browser version is 121.0.6167.139
    • How to run auto-tests via specific webdriver that I will put in repo instead of webdriver that generated automatically by protractor?
    • Running protractor e2e with custom build and serve configuration
    • Angular E2E Protractor testing : error to join API from testing session
    • Protractor: Webdriver-manager update downloads an incompatible version of chromedriver
    • webdriver manager update only to chrome driver version 114
    • My chrome version got updated automatically to 115 version and when i run webdriver-manager update command why its downloading 114 version of chrome?
    • Vscode keep running tests or run on save
    • Access AngularJS's scope in Playwright (migration from protractor)?
    • Difference b/w running test cases in angular frameworks vs the compiler default?
    • Is there a way to get the jasmine report without actual execute cases?
    • Jenkins not running a few protractor tests
    • Can't run protractor tests with selenium hub 4
    • How to capture scenario result in cypress-cucumber-preprocessor?
    • Protractor:Chrome driver download failed because api blocked by my company

    Related Questions in END-TO-END

    • What's the best way to breakup a large test in pytest
    • Login works when app run but fails in Selenide test
    • Multi user test with jest in parallel run
    • Cypress 'have.text' assertion coming up with doubled-up values
    • How to imitate gRPC response from server for end to end testing for a grpc client in dotnet
    • How to create an encrypted password with mixer for Django testing?
    • In Karate end to end testing not able to select element like 34(awesome) from search dropdown filtered options
    • How to login programatically in Cypress E2E test using Next Auth JWT
    • Static map property in a class causing Babylon error
    • How can you do end-to-end UI testing for Telegram bots?
    • How to make "ad-hoc" API call to Rails server in the context of default Rails testing framework
    • Generate html report from jacoco agent inside a docker container
    • Internal Service Error when testing fastapi views
    • How to close the firefox nightly translation popup with Playwright?
    • Automate DOM interactions within browser w/o development server

    Trending Questions

    • UIImageView Frame Doesn't Reflect Constraints
    • Is it possible to use adb commands to click on a view by finding its ID?
    • How to create a new web character symbol recognizable by html/javascript?
    • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
    • Heap Gives Page Fault
    • Connect ffmpeg to Visual Studio 2008
    • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
    • How to avoid default initialization of objects in std::vector?
    • second argument of the command line arguments in a format other than char** argv or char* argv[]
    • How to improve efficiency of algorithm which generates next lexicographic permutation?
    • Navigating to the another actvity app getting crash in android
    • How to read the particular message format in android and store in sqlite database?
    • Resetting inventory status after order is cancelled
    • Efficiently compute powers of X in SSE/AVX
    • Insert into an external database using ajax and php : POST 500 (Internal Server Error)

    Popular # Hahtags

    javascript python java c# php android html jquery c++ css ios sql mysql r reactjs node.js arrays c asp.net json

    Popular Questions

    • How do I undo the most recent local commits in Git?
    • How can I remove a specific item from an array in JavaScript?
    • How do I delete a Git branch locally and remotely?
    • Find all files containing a specific text (string) on Linux?
    • How do I revert a Git repository to a previous commit?
    • How do I create an HTML button that acts like a link?
    • How do I check out a remote Git branch?
    • How do I force "git pull" to overwrite local files?
    • How do I list all files of a directory?
    • How to check whether a string contains a substring in JavaScript?
    • How do I redirect to another webpage?
    • How can I iterate over rows in a Pandas DataFrame?
    • How do I convert a String to an int in Java?
    • Does Python have a string 'contains' substring method?
    • How do I check if a string contains a specific word?

    Copyright © 2021 Jogjafile Inc.

    • Disclaimer
    • Privacy
    • TOS
    • Homegardensmart
    • Pricesm.com
    • Aftereffectstemplates