I encountered an issue where I couldn't write a value to a field using Selenium's .sendKeys. As a workaround, I decided to use the following jsCode:
element = xpath(//pre[@role='presentation'])
executeJavaScript("arguments[0].value='RESPONSE';", element)
Additionally,
executeJavaScript("arguments[0].setAttribute('value', 'RESPONSE')", element);
I am puzzled as to why these methods are not working - although the test passes, the value is not being written to the field.
$("div pre").append("RESPONSE")
- this line works in devTools.
Here is the full HTML code snippet:
<body>
<div style="position: relative;">
<div aria-hidden="true" class="CodeMirror-gutter-wrapper" style="left: -30px;">
<div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">
1
</div>
</div>
<pre class="CodeMirror-line" role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span></span></span></pre>
</div>
</body>