0

I am using python 3.9 and selenium 4.6.0 on Chrome. I have a script that needs to upload a file to an input, this works fine on local but fails when run on RemoteDriver. The code I am using is

driver.find_element(By.XPATH, "//input[@accept]").send_keys('path to file')

When run on RemoteDriver the error returned is

selenium.common.exceptions.WebDriverException: Message: unknown command: unknown command: session/cddd71e067d7717481fb8a635103c643/se/file

I've think it is due to this line in the remote_connection.py file in selenium

Command.UPLOAD_FILE: ('POST', "/session/$sessionId/se/file")

From the research I've done the 'se' in this case is a 'vendor_prefix' for selenium but I cannot figure out how to either configure the remote driver to use a vendor prefix or remove that from POST path that is being passed (short of pulling my own version of the code and maintaining that).

For other functional reasons I can't revert to selenium 3x (which is an option I've seen to correct this), nor can I set w3c to False. Does anyone know how to work around this particular issue; either by getting send_keys to operate as expected in this situation or using another method to upload the file? Thanks.

  • that'll be specific to a certain driver... for remote you need to use a localFileDetector, though. Are you doing that? (ex: https://stackoverflow.com/questions/62595459/how-to-upload-a-file-by-transfering-the-file-from-the-local-machine-to-the-remot ) Also remember that only a Selenium grid would understand this command.. (I think it'll ignore the "vender_prefix".) – pcalkins Nov 16 '22 at 21:19
  • I think the 'only selenium grid will understand' might've answered my question. We're using aws device farm and a home grown framework. For what it's worth, I did try setting the local file detector but encountered the same issue `from selenium.webdriver.remote.file_detector import LocalFileDetector driver.file_detector = LocalFileDetector()` – user2201221 Nov 17 '22 at 11:24
  • so the framework has to know there's a file coming in as an upload, and then it sets the value to it's own local path. – pcalkins Nov 17 '22 at 17:55

0 Answers0