title: How can I prompt for input using Selenium/Webdriver and use the result?
body: <p>I would like to allow for user input and make some decisions based on it. If I do this:</p>
  
  <pre><code>driver.execute_script("prompt('Enter smth','smth')")
  </code></pre>
  
  <p>I get a nice prompt, but I cannot use it's value. Is there any way of showing an input box to the user, and use the value typed there?</p>
  
  <p>EDIT: This is my script:</p>
  
  <pre><code>from selenium.webdriver import Firefox
  
  if __name__ == "__main__":
      driver = Firefox()
      driver.execute_script("window.promptResponse=prompt('Enter smth','smth')")
      a = driver.execute_script("var win = this.browserbot.getUserWindow(); return win.promptResponse")
      print "got back %s" % a
  </code></pre>
  
  <p>And this exits with the following exception:</p>
  
  <pre><code>    a = driver.execute_script("var win = this.browserbot.getUserWindow(); return win.promptResponse")
    File "c:\python26\lib\site-packages\selenium-2.12.1-py2.6.egg\selenium\webdriver\remote\webdriver.py", line 385, in ex
  ecute_script
      {'script': script, 'args':converted_args})['value']
    File "c:\python26\lib\site-packages\selenium-2.12.1-py2.6.egg\selenium\webdriver\remote\webdriver.py", line 153, in ex
  ecute
      self.error_handler.check_response(response)
    File "c:\python26\lib\site-packages\selenium-2.12.1-py2.6.egg\selenium\webdriver\remote\errorhandler.py", line 110, in
   check_response
      if 'message' in value:
  TypeError: argument of type 'NoneType' is not iterable
  </code></pre>
  
  <p>What am I not doing right?</p>
  
  <p>EDIT: I tried to do like prestomanifesto suggested, here's the output:</p>
  
  <pre><code>In [1]: from selenium.webdriver import Firefox
  
  In [2]: f = Firefox()
  
  In [3]: a = f.ex
  f.execute              f.execute_async_script f.execute_script
  
  In [3]: a = f.execute_script("return prompt('Enter smth','smth')")
  
  In [4]: a
  Out[4]: {u'text': u'Enter smth'}
  
  In [5]: a
  Out[5]: {u'text': u'Enter smth'}
  
  In [6]: class(a)
    File "&lt;ipython-input-6-2d2ff4f61612&gt;", line 1
      class(a)
           ^
  SyntaxError: invalid syntax
  
  
  In [7]: type(a)
  Out[7]: dict
  </code></pre>