user27591692
user27591692

Reputation: 1

How to upload a file using Selenium when HTML element is hidden?

I am working in a project using Selenium with Python. I need to upload a file, but different from other places, the filetype input is not available. I thought it was only hidden, but it seems that the input only appears after clicing in the upload button. I guess there is a script or something that makes it appears, but I don't know how to solve it.

Before clicking:

<div>
  <div class="input-group">
    <input type="text" class="form-control" readonly="" placeholder="Arraste um arquivo aqui ou clique no botão para pesquisar" value="" style="">
    <div class="input-group-btn">
      <button title="Selecionar" type="button" class="btn btn-default"> 
        <span class="fa fa-upload"></span>
      </button>
      <ul class="dropdown-menu pull-right"></ul>
    </div>
  </div>
</div>

After clicking:

<div>
  <div class="input-group">
    <input type="text" class="form-control" readonly="" placeholder="Arraste um arquivo aqui ou clique no botão para pesquisar" value="" style="">
    <div class="input-group-btn">
      <button title="Selecionar" type="button" class="btn btn-default">
        <span class="fa fa-upload"></span>
      </button>
      <ul class="dropdown-menu pull-right"></ul>
    </div>
    <input type="file" class="input_arquivo hidden">
  </div>
</div>

I have just managed to upload it after clicking the button, (the code fails if the button is not clicked) but the upload screan appears and I don't know how to close it or achieve it in another way

Upvotes: 0

Views: 44

Answers (0)

Related Questions