Ok, so this is a little difficult to explain so I shall start with the words and then get into a bit of code. I am using a database software called airtable, which does not allow me to upload images through the API. However a user can upload an image through a form submission, which creates a new record in the base. I am getting around the lack of automated uploading by using Selenium and opening the webform, then entering the data as a user. The problem I have run into is when I try and upload a file. I cannot send the filepath to the attachment space, and it seems that I am forced to interact with the windows File Explorer popup instead. I have read the answers to this question, and tried using win32com, autoit, and the selenium switch to window functions. All without apparent results. So that is the state of things here, and I shall now show an example of what I am trying to do.
First up I have this code, which opens the form seen below it. Url and driver_path are defined, but not shown here
driver = webdriver.Firefox(executable_path=driver_path)
driver.get(url)
Image of the form as it opens initially
Now I have tried to pass a filepath here, but none of the objects seem to be reachable by keyboard. Instead I use this brief code to click on the button
attach = driver.find_element_by_xpath("//div[@class='fsp-drop-area']")
attach.click()
And this button press opens a new window in the webpage, which looks like this: Image of form after click
Again, I have tried to pass a filepath here, but it does not seem to be keyboard addressable. As a user interacting with this form I can either drag and drop a file, or click the button to open windows File Explorer. The second option is what the code below does.
attach = driver.find_element_by_xpath("//div[@class='fsp-drop-area']")
attach.click()
And now I am left with this: Image of form with windows explorer open and I am unable to interact with it from python. I cannot seem to address it to find out what the name of the file search box at the bottom is, and I cannot send key strokes to it despite the file name search bar being highlighted when it opens. Earlier in the script I saved the photo I am now trying to upload, so I know its full filepath and could search for it if I can just access that box. I have not tried doing it graphically because this code will be put on a couple computers, and they do not have the same displays.
Any help would be very welcome.