• 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-16T10:05:35.237683

    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

    • Angular Show All When No Filter Is Supplied
    • Why does a function show up as not defined
    • I count the time the user takes to solve my quiz using Javascript but I want the same time displayed on another page
    • Set "More" "Less" font size
    • Using pagination on a table in AngularJS
    • How to sort these using Javascript or Jquery Most effectively
    • how to fill out the table with next values in array with one button
    • State with different subviews
    • Ajax jQuery firing multiple time display event for the same result
    • Getting and passing MVC Model data to AngularJS controller
    • Disable variable in eval
    • javascript nested loops waiting for user input
    • .hover() seems to overwrite .click()
    • How to sort a multi-dimensional array by the second array in descending order?
    • How do I find the fonts that are not loading in a CORS situation ( MoovWeb )?

    Related Questions in SELENIUM

    • How to access invisible Unordered List element with Selenium WebDriver using Java
    • Compound classes stored in an array are not accessible in selenium java
    • Fail Upload file in Selenium webdriver using Robot class
    • Selenium crashes Firefox, how to reset the used profile / where is the default profile?
    • Selenium Driver Service not found exception
    • Unable to read excel if cell/column has drop down list enabled for Selenium webdriver TestNG
    • Selenium C#: Store element's position on graph as a variable
    • Selenium webdriver for handling dynamic ckeditors
    • What can cause `UnreachableBrowserException: Could not start a new session`?
    • Click on the 'compose' button in gmail inbox page
    • python - selenium change frame not working
    • Selecting Options from a Drop Down Menu in C# using Selenium
    • Validation without skipping the test cases if one fails
    • How can i increase session timeout (which is 30 minutes by default)
    • Load additional CONFIG file with values

    Related Questions in TESTING

    • How does Robot's Telnet library work?
    • Behat doesn't load extensions?
    • Load additional CONFIG file with values
    • rails controller test failing non-deterministicly wrt state leak (I think)
    • Ordering tests using trial twisted
    • Unexcepted failed Gavel/Dredd test
    • How to use Jasmine and CucumberJS with Protractor
    • Django login tests session problems
    • How to mock specific RequireJs dependencies while unit testing
    • Test case for WCF REST Service
    • how to test this business logic
    • Protractor - How to get first or last CHILD value
    • Factory Not Registered in rspec but found in console
    • Pick out certain lines from files
    • Selenium stops running after click() function runs

    Related Questions in PROTRACTOR

    • Protractor did not run properly when using browser.wait, msg: "Wait timed out after XXXms"
    • Getting the button text in Protractor
    • MSSQL - Nodejs - Undefined is not a function issue
    • Load additional CONFIG file with values
    • Protractor, login to asp,net MVC login page, wait for default page then , redirect to angular page and do tests....how?
    • Phantomjs fails when Protractor is run with selenium hub
    • Protractor Test Result variations
    • How to use Jasmine and CucumberJS with Protractor
    • Protractor : Failed: Object has no method 'getText'
    • Protractor - How to get first or last CHILD value
    • Protractor : Refreshing browser instance between testsuites
    • Protractor e2e tests with MEANJS navigation
    • Protractor: Multiple browser instance tests fail where Single Instance tests pass
    • cucumber-js and Chai how to expect if element with given selector exist in DOM
    • How to use isElementPresent/isPresent inside ng-repeat in protractor?

    Related Questions in END-TO-END

    • Protractor did not run properly when using browser.wait, msg: "Wait timed out after XXXms"
    • Load additional CONFIG file with values
    • Protractor scrolling through executeScript not working
    • How to get the value from selectbox?
    • Use the same variable in each test file
    • Get attribute from table - Protractor
    • Element is not clickable at point - Protractor
    • Protractor wait for db connection
    • Should I use ids to locate elements?
    • Protractor: Click on SVG element not work
    • Upload file - Protractor
    • Protractor - Storing a value for later use
    • Click on element - Protractor
    • Protractor - find element in iframe
    • Protractor with jest assertion framework

    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

    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
    • Math
    • Aftereffectstemplates