I am writing some cypress
test for the Codemirror Editor. I have use cypress
to type in the input field.
I am trying to achieve the cy.type()
in the CodeMirror Editor. The Data I have in codemirror is inside the span.
<pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> < h1 > Welcome to your web project canvas! < /h1></span></pre>
The cypress spec code cy.get('pre.CodeMirror-line') .type('Cypress HTML Data')
I am not able to type some data using cypress.
I would appreciate if someone can help?
You're not targeting the correct element in your spec code. You're doing
cy.get('pre.CodeMirror-line')
, but a<pre>
tag is not acy.type()
-able element.You need to get the hidden CodeMirror
<textarea>
instead. This can be selected using.CodeMirror textarea
. The following JS is a demo spec that works oncodemirror.net
: