I can't write value to field using Selenium .sendKeys. So I use jsCode:
element = xpath(//pre[@role='presentation'])
executeJavaScript("arguments[0].value='RESPONSE';", element)
and
executeJavaScript("arguments[0].setAttribute('value', 'RESPONSE')", element);
I can't understand why these methods don't work - the test passes but the value is not written to the field
$("div pre").append("RESPONSE")
- work in devTools
Full html code:
<body>
<div style="position: relative;">
<div aria-hidden="true" style="left: -30px;">
<div style="left: 0px; width: 21px;">
1
</div>
</div>
<pre role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span></span></span></pre>
</div>
</body>
CodePudding user response:
If you are trying to append to the content of the pre
tag then use something like executeJavaScript("arguments[0].append('RESPONSE')", element);
. That should append the response to the element in arguments[0]
.
If you are trying to set an attribute named value
to the pre
element. Then "arguments[0].setAttribute('value', 'RESPONSE')"
sets <pre role='presentation' value="RESPONSE">
.