title: Python-Selenium "input type file" upload
body: <p>I'm trying to upload a file to a website using python and selenium. I tried following methods </p>
  
  <pre class="lang-py prettyprint-override"><code>driver = webdriver.Firefox()
  driver.get("ip-address")
  </code></pre>
  
  <p>method 1:</p>
  
  <pre class="lang-py prettyprint-override"><code>test = driver.find_element_by_id("selectedFile")
  test.send_keys('/Users/knightfox/Desktop/file.txt')
  </code></pre>
  
  <p>method 2:</p>
  
  <pre class="lang-py prettyprint-override"><code>test = driver.find_element_by_xpath("//input[@type='file']")
  test.send_keys('/Users/knightfox/Desktop/file.txt')
  </code></pre>
  
  <p>method 3:</p>
  
  <pre class="lang-py prettyprint-override"><code>test = driver.find_element_by_css_selector('input[type="file"]')
  test.send_keys(r'/Users/knightfox/Desktop/file.txt')
  </code></pre>
  
  <p>But I get following errors when execute. </p>
  
  <pre><code>Traceback (most recent call last):
    File "/home/knightfox/Desktop/bell/sel.py", line 18, in &lt;module&gt;
      test.send_keys(r/Users/knightfox/Desktop/file.txt)
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 479, in send_keys
      'value': keys_to_typing(value)})
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 628, in _execute
      return self._parent.execute(command, params)
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
      self.error_handler.check_response(response)
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
      raise exception_class(message, screen, stacktrace)
  selenium.common.exceptions.ElementNotInteractableException: Message: Element &lt;input id="selectedFile" name="file" type="file"&gt; is not reachable by keyboard
  </code></pre>
  
  <p>I'm using Python 2.7. Following is the html page.</p>
  
  <p><a href="https://i.stack.imgur.com/uCKSP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uCKSP.png" alt="enter image description here"></a></p>
  
  <p>Update:</p>
  
  <p>Following code by Ian solved the issue.</p>
  
  <pre><code>field = driver.find_element_by_id("selectedFile")
  driver.execute_script("arguments[0].style.display = 'block';", field)
  field = driver.find_element_by_id("selectedFile")
  field.send_keys('/Users/knightfox/Desktop/file.txt')
  </code></pre>