Upload bottom on click call a javascript

Hi, I’m having issues with this field where I have to upload a file
I suppose to click on bot choose the file and soon as I click on it sends
the problem is choose file does not allow that to happen, I do see that the file is attached on the field but it keeps waiting for the action on click

here is what I got

> <div class="row marginTop">
>             <div class="form-group">
>               <div class="form-group col-md-4 text-center">
>                 <span class="file-input-wrapper btn btn-info btn-block" id="btnAnexarNotaTecnica">
>                   Anexar Nota Técnica
>                   <input type="file" id="anexarNotaTecnica" name="anexarNotaTecnica" data-url="/ecm/upload" onclick="formController.controlarBotoesAnexo(this, AcaoAnexo.ANEXAR, 'notaTecnica');" style="height: 100%; width: 100%;" value="">
>                 </span>
>               </div>
>               <div class="form-group col-md-4 text-center">
>                 <button type="button" id="visualizarNotaTecnica" onclick="formController.controlarBotoesAnexo(this, AcaoAnexo.VISUALIZAR, 'notaTecnica')" class="btn btn-block btn-success" disabled="">Visualizar
>                   Nota Técnica</button>
>               </div>
>               <div class="form-group col-md-4 text-center">
>                 <button type="button" id="excluirNotaTecnica" onclick="formController.controlarBotoesAnexo(this, AcaoAnexo.EXCLUIR, 'notaTecnica')" class="btn btn-block btn-danger" disabled="">Excluir
>                   Nota Técnica</button>
>               </div>
>             </div>
>           </div>

and here is the robot part where I tried to deal with this field

# #Wait Until Element Is Visible    ${CLICAR_NOTA} 

# # Click Element    ${CLICAR_NOTA} 
# # Press Keys    ${CLICAR_NOTA}    ${CURDIR}/teste.pdf
# #Execute Javascript    formController.controlarBotoesAnexo(this, AcaoAnexo.ANEXAR, 'notaTecnica');
# Execute JavaScript    formController.controlarBotoesAnexo(this, AcaoAnexo.ANEXAR, 'notaTecnica');  document.getElementById("anexarNotaTecnica").onclick()
# Click Element    ${CLICAR_NOTA}
# Execute JavaScript    arguments[0].style.display='block';    ${CLICAR_NOTA}
Choose File    ${CLICAR_NOTA}       ${CURDIR}/teste.pdf
Submit Form    css:form[name="form"]
Wait Until Element Is Visible    ${CLICAR_NOTA_TECNICA} 
Click Element    ${CLICAR_NOTA_TECNICA}

Is this site publicly available?

it is not. you need more part of the site ? I can paste here

And you get no error, just click does not happen? If you use Highlight Elements does element gets highlight?

so the problem is this robot is running headless, on a container, so we don’t use the click to attach the file

I was trying to see a away to run the script that formController calls, and it did run, but nothing happens.

I can see that choose file added test.pdf to be uploaded, but when we call the formcontrole js it does nothing

And also Click Element does nothing and does not produce an error? Maybe it would work with JS, something like document.querySelector("#excluirNotaTecnicar").click()?

Click element will open the dialog to attach the document. but it’s being run on a pipeline inside of a container, so there is no graphics, wont help to click on because won’t open the dialog to attach the file. but to respond your question, no it does not give any error.
I will give some tries with that open querySelector

There is anyway to change the this field

<input type="file" id="anexarNotaTecnica" name="anexarNotaTecnica" data-url="/ecm/upload" onclick="formController.controlarBotoesAnexo(this, AcaoAnexo.ANEXAR, 'notaTecnica');" style="height: 100%; width: 100%;" value="">

on something like

<input type="file" id="anexarNotaTecnica" name="anexarNotaTecnica" data-url="/ecm/upload" onchange="formController.controlarBotoesAnexo(this, AcaoAnexo.ANEXAR, 'notaTecnica');" style="height: 100%; width: 100%;" value="#{CURDIR}//test.pdf">

The solution:

looks like this is a promises that get this and 2 other parameters and call the js
formController.controlarBotoesAnexo(this, AcaoAnexo.ANEXAR, ‘notaTecnica’);
so we call the script like this
formController.anexarListaArquivos(window.document.getElementById(‘anexarNotaTecnica’), ‘arquivosDocsDispensa’, ‘listaDocsDispensa’);

with get element by id replacing this, that way when we call the js it prepares the promises to run
just after we add the file
Choose File ${CLICK_ANEX} ${CURDIR}/test.pdf
Sleep 15s
and add 15s for the script run.
works clean for me

1 Like