Python Forum

Full Version: file upload from windows10 machine using send_key in selenium fails
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I am using python2.7.6, selenium 3.8.1, Windows 10 and Chrome browser

When I upload a file using selenium send_keys command, it fails with File not found error though the file is present:

>>> driver.find_element_by_css_selector('input[type=file].inputMetadataFile')
<selenium.webdriver.remote.webelement.WebElement (session="721fe652a589f67f90d089b5038ea579", element="0.4043670881107271-1")>
>>> driver.find_element_by_css_selector('input[type=file].inputMetadataFile').send_keys(r"C:\Python27\Scripts\metadata")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 479, in send_keys
'value': keys_to_typing(value)})
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 628, in _execute
return self._parent.execute(command, params)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 237, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: invalid argument: File not found : C:\Python27\Scripts\metadata
(Session info: chrome=63.0.3239.132)
(Driver info: chromedriver=2.34.522940 (1a76f96f66e3ca7b8e57d503b4dd3bccfba87af1),platform=Windows NT 10.0.15063 x86_64)

Please help.
Sounds like the file doesn't exist?
Is metadata a file?
For Windows is much more common that all files have a file extension.
So eg metadata.txt or that metadata is a folder with a file inside metadata\foo.txt.
there was a bug for firefox, but maybe there is one for chrome maybe. Not sure as i am not familiar with this section.