title: Remove readonly attributes in Selenium WebDriver
body: <p>I need to edit some <code>readonly</code> fields with Selenium WebDriver in Java. As Selenium won't let me even find this fields I searched for solutions and found that the easiest might be to remove the <code>readonly</code> attribute using a JavaScript snippet with the <a href="http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/JavascriptExecutor.html" rel="nofollow noreferrer">JavaScript Executor</a>.</p>
  <p>While this snippet works from the Firefox console, successfully removing the attribute from all inputs, it throws an exception in Selenium.</p>
  <p>JavaScript executor:</p>
  <pre><code>((JavascriptExecutor) driver).executeScript(
      &quot;var inputs = document.getElementsByTagName('input');​​​​&quot;+
      &quot;for(var i = 0; i &lt; inputs.length; i++)&quot;+
          &quot;inputs[i].removeAttribute('readonly','readonly');​​​​&quot;
  );
  </code></pre>
  <p>And the error returned:</p>
  <blockquote>
  <p>Exception in thread &quot;main&quot; org.openqa.selenium.WebDriverException: illegal character</p>
  <p>Command duration or timeout: 51 milliseconds</p>
  </blockquote>
  <p><strong>UPDATE:</strong></p>
  <p>The same error appears if I leave only the first JS command:</p>
  <pre><code>((JavascriptExecutor) driver).executeScript(
      &quot;var inputs = document.getElementsByTagName('input');​​​​&quot;);
  </code></pre>
  <hr />
  <p>The rest of the stack trace is not relevant for this. Anyone knows how to fix this, or another way to edit the <code>readonly</code> fields?</p>