Click the plus button in the ChatGPT UI?

A week ago I wrote a script that could click the plus button in the ChatGPT UI to open the submenu where you then could choose to upload a file to ChatGPT either from your computer or from Google Drive or One Drive.

Using Chrome I did something like this:

set XPPlusButton to "//div/div/div[2]/form/div[1]/div/div[2]/div/div[1]/div[1]/div/div/span[2]/button"
execute javascript "document.evaluate('" & XPPlusButton & "', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue?.click();"

(Now the XPath has changed to something like //*[@id='upload-file-btn']" )

This doesn’t work anymore and I have no idea why. As far as I can tell, the button element is very normal and it generates a DOMWindow.click event when clicked.

My overall goal is to upload a file from my computer but it is not allowed to open the file chooser from a script. Therefore, I want to click this plus button to open the submenu and then send some keyboard events to open the file chooser. I am open to suggestions to solve this problem if there are other ways to achieve this.


This is the plus-button:

image

I wonder if it can be done easier via GUI scripting in the desktop app, MacGPT?