Currently, I am attempting to input text into a textarea field that is recognized as CodeMirror. Below is the code snippet I have been working with:
{...
WebElement scriptField =
this.getDriver().findElement(By.cssSelector(".CodeMirror-line>span"));
JavascriptExecutor js = (JavascriptExecutor) this.getDriver();
String query = "text";
js.executeScript("arguments[0].CodeMirror.setValue(\""+ query +"\");", scriptField);
}
However, I encountered an error on the last line of my code:
org.openqa.selenium.WebDriverException : unknown error: Cannot read property 'setValue' of undefined
I am unsure which webelement the scriptField variable should be referring to. When I manually type text, it appears in this element: ".CodeMirror-line>span"
. Can someone confirm if my understanding is correct?
An excerpt of the DOM structure can be seen in the attached image below.