I have an Angular form where I should upload a file. Normally I would just use the .sendKey(filePath) method to set the input field's value, but in this case, it is not possible.
Here is the code of the form:
<div class="input-group">
<div class="input-container">
<div class="file-input-list">
<!---->
</div>
<input readonly="" type="text" class="form-control file-name-input" id="ec5e0202-5022-4df3-9f9b-2e4f1b0fc994" placeholder="">
</div>
<div class="input-group-append">
<button type="button" class="btn btn-outline-primary btn-form-control"> Select file </button>
</div>
</div>
As you can see, I have a read-only text field (with a randomly generated ID to make things easy), and a sole button that launches the file browser window. If I select a file from that window, it will appear as a chip in the file-input-list.
I tried using driver().switchTo().activeElement().sendKeys(filePath); but it is unable to set the filePath in the apperaring window.
I also looked for a hidden file type input field, but there isn't any.
Is there any way to somehow automate the file selection, or forcibly add the file to the file-input-list?