I am trying to write a script that can upload a .tar file from my local computer. Since I have multiple upload.tar files, I would ideally like it to upload the most recent upload.tar file based on "Date Created". I included a link to the input field/button below 1. You cannot enter text into the input field, but it shows the file name after you select it. Clicking on 'Choose File' opens the MacOS window to search and select the local file.
I tried driver.find_element(By.id, "root_file_upload").sendKeys("PATH") but that failed. I also found that driver.find_element(By.XPATH, "//span[@class='buttonText']").click() opens the Mac window and kills the test. I'm feeling confident that a Javascript executescript is necessary, but am unfamiliar with how to incorporate that into Selenium/Python3 code. I'm also testing in Chrome browser. Could someone help guide me on how to build out a script that can upload a local file (upload.tar) with a field that isn't editable?
Here is the inspected code:
<form action="/record/sandbox/consume" name="sandbox-upload-form" method="post" enctype="multipart/form-data">
<input type="file" name="hep_archive" id="root_file_upload" data-iconname="fa fa-upload" class="filestyle" tabindex="-1" style="position: absolute; clip: rect(0px, 0px, 0px, 0px);">
<div class="bootstrap-filestyle input-group">
<input type="text" class="form-control " placeholder="" disabled="">
<span class="group-span-filestyle input-group-btn" tabindex="0">
<label for="root_file_upload" class="btn btn-default ">
<span class="icon-span-filestyle fa fa-upload"></span>
<span class="buttonText">Choose file</span></label></span></div>
<br>
<input type="submit" value="Upload and Process" class="btn btn-primary" onclick="HEPDATA.hepdata_record.perform_upload_action(event, '#sandbox-upload-area', 'sandbox-upload-form', ['#955BA5', '#2C3E50'], 'large_area')">
</form>