title: Replace a string in a textarea using selenium, "not reachable by keyboard"
body: <p>I'd like to modify part of the text in a textarea with Selenium. The textarea seems almost as if it were read-only.</p>
  
  <p>In this very simple example using a sample algo, it would be great to be able to change the stock id on this line:</p>
  
  <pre><code>context.aapl = sid(24)
  </code></pre>
  
  <p>... to something like:</p>
  
  <pre><code>context.aapl = sid(39840)
  </code></pre>
  
  <p>... which is the Tesla stock id. The variable name will no longer make sense, doesn't matter, just a start.</p>
  
  <p>This Selenium code for me is able to open the sample with no login required.</p>
  
  <pre><code>from selenium import webdriver
  from selenium.webdriver.common.keys import Keys
  
  t = webdriver.Firefox()     # t stands for tab as in browser tab in my mind
  t.implicitly_wait(10)
  t.get('https://www.quantopian.com/algorithms/')
  o = t.find_element_by_xpath("//body")       # o stands for object
  o.send_keys(Keys.ESCAPE)                    # clearing the popup
  o = t.find_element_by_link_text("Hello World Algorithm")
  o.click()
  ''' for the fun of it if you want to run the backtest
  o = t.find_element_by_xpath('//body')
  o.send_keys(Keys.CONTROL + 'b')
  o.send_keys(Keys.ESCAPE)
  '''
  print t.find_element_by_id('code-area').text
  </code></pre>
  
  <p>Here's the output from that</p>
  
  <pre><code>1
  # Called once at the start of the simulation.
  2
  def initialize(context):
  3
      # Reference to the AAPL security.
  4
      context.aapl = sid(24)
  5
  6
      # Rebalance every day, one hour and a half after market open.
  7
      schedule_function(my_rebalance,
  8
          date_rules.every_day(),
  9
          time_rules.market_open(hours=1, minutes=30))
  10
  11
  # This function was scheduled to run once per day at 11AM ET.
  12
  def my_rebalance(context, data):
  13
      14
      # Take a 100% long position in AAPL. Readjusts each day to
  15
      # account for price fluctuations.
  16
      if data.can_trade(context.aapl):
  17
          order_target_percent(context.aapl, 1.00)
  </code></pre>
  
  <p>That id is 'code-area'. The content includes margin numbers which might be a problem. 
  Next nested area is 'code-area-internal', seems the same. 
  Followed by these two. </p>
  
  <pre><code>&lt;div class='ide-container' id='ide-container'&gt;
  &lt;textarea class='width_100pct' id='codebox'&gt;
  </code></pre>
  
  <p>In trying to obtain the content of the algorithm with 'codebox', content doesn't appear to be present, just u'' ...</p>
  
  <pre><code>&gt;&gt;&gt; p = t.find_element_by_id('codebox').text
  &gt;&gt;&gt; p
  u''
  </code></pre>
  
  <p>Attempt to do CTRL-A on it results in this exception...</p>
  
  <pre><code>&gt;&gt;&gt; o = t.find_element_by_id('codebox')
  &gt;&gt;&gt; o.send_keys(Keys.CONTROL + 'a')
  </code></pre>
  
  <p><strong>ElementNotInteractableException: Message: Element  is not reachable by keyboard</strong></p>
  
  <p>If the text can be completely cut, then replace can done in Python and paste, that would be fine. 
  I wouldn't expect Selenium to be able to find and replace text, just surprised it finds a visible area for user input to be off limits from interactivity.</p>
  
  <p>That textarea does have its own Find, and hoping won't have to resort to trying to use it as a workaround.</p>
  
  <p><em>(The environment is an online IDE for stock market algorithms called Quantopian)</em></p>
  
  <p>This is the one other thing I tried, with no apparent effect:</p>
  
  <pre><code>&gt;&gt;&gt; t.execute_script("arguments[0].value = arguments[1]", t.find_element_by_id("ide-container"), "_new_")
  </code></pre>
  
  <p>Appreciate any pointers.</p>