I want to use Java Selenium to upload the file in the following input element(upload element).
<input type="hidden" ng-model="model[options.key || index]"
id="formly_21_fileupload_args_content_substrate_surface_media_documentURL_0"
name="formly_21_fileupload_args_content_substrate_surface_media_documentURL_0"
formly-custom-validation="options.validators"
class="ng-pristine ng-untouched ng-invalid ng-invalid-wizard-validation">
I have tried to use 'sendKeys' but got the error informatoion:
upload.sendKeys("filePath"); // element is invisible
then I tried to use JavascriptExecutor in the script to change the visibility of the Element (type="file"), but still got the same error: element is invisible:
JavascriptExecutor jsexec = (JavascriptExecutor) driver;
jsexec.executeScript("arguments[0].type='file'", upload);
I also tried to use the parent element 'div' to do the upload, but got the error "cannot focus the element".
is there anyone can help me to solve this problem?