Search code examples
javascriptseleniumselenium-webdrivercodemirror

Programmatically edit CodeMirror contents without access to object


I'm using Selenium to run automated tests on a page which contains a CodeMirror editor. I don't have access to the object however I do have jQuery available. How can I edit the contents of the editor in such a way that CodeMirror recognises the change?


Solution

  • The wrapping div DOM element (with class CodeMirror) will have a property CodeMirror that refers to the editor instance object. You can call setValue on that.