Choose file not working properly

Hi, guys. Could you help me with this issue? I have two scenarios here:
1 - I’m using choose file xpath/class ${path} in a field that a can select only one image. In this particular case, to change the background of the page, and it is working perfectly. I have a input field where the image is stored.

2 - I have have a button to upload one or more images, so it is a list. The list will be only showed when i sent the fist images. I used the same method of the first case, using choose file and the log says that i have sent the image, but it wasn’t. I think this is happening because its is a list, right? In this case, i don’t have a input field, only

  • with the image.

    ** wait until element is visible class:btn-anexar**
    ** Choose File class=btn-anexar ${EXECDIR}/Assets/Img/Led.png**
    ** Log To console worked**

    in this attemp, i’m trying to store the button. it is just to show to you guys that i tryed with the list components and I didn’t get result.

    the next step isn’t working because the image was not sent to the page…

    Can you understand me? I’m still learning english :wink:

  • Hello,

    Your English is fine.

    I assume that the image was correctly uploaded, but the next action to trigger the showing of the image did not happen.

    Usually, the user clicks on the button and that should trigger the call of other functions or changes in variables. There could also be a problem of timing. You send the image and the you test if it was visible. Maybe this is too soon.

    You should try to make some action, for example Mouse Down on a element related to the image.

    Other problem that can happen, is to send the file to a different element. You are using a class as selector, but Choose File may be just using the first element it found. You should try to see if there are more elements of <input type=‘file’ … > and use a better locator if that is the case.


    Choose File does NOT address the button that triggers the upload.
    You have to select the <input > element that will contain the path to that file after it is chosen.

    Inputs the file_path into the file input field locator .

    1 Like

    Hi, guys. I asked to the developer change de to and worked. :slight_smile: thank you.

    Great answer. I was stuck on this for very long. Got it work finally :slight_smile:

    What if the application does not have input tag and with attribute type='file, what is the alternate solution to this problem.

    I am facing this issue from a long time

    Then it is not a standard HTML page, or you missed to find the correct element.

    Our application does not support input tag for the upload button, we have button tag with span in the inner div, Is there any other way to upload?

    I have already checked with the developer but they said they cannot change it to upload.

    Can you please help

    Somewhere in the page, there is an input element to receive the file. You need to track the actions of that button that will make the connection to the input element.

    Generally I would agree with @HelioGuilherme66 on this, there really should be an input of type file hidden somewhere in the html page.

    I have however once seen an exception to this where the upload button actually triggered a file selector from javascript and then did the upload via a webservice call and once successful used used a callback to update the page to show the filename as uploaded. Now this is NOT standard html or standard anything really but I did see it once.

    I suggest you load the page, open dev tools (typically F12) to the network tab, clear the network tab and then upload a small file and see what network traffic is generated, inspect the post data of all your posts, and this should give you a clue to how the files are being uploaded.

    Once you know what the browser does manually then you can plan an approach to automate it.

    Hope this helps,