I need to put the cursor in the textarea element using Selenium. The element has no ID. I have tried:
eventDriver.findElement(By.cssSelector("textarea[class*=\"CodeMirror\"")).click();
and it throws NoSuchElementException
I need to put the cursor in the textarea element using Selenium. The element has no ID. I have tried:
eventDriver.findElement(By.cssSelector("textarea[class*=\"CodeMirror\"")).click();
and it throws NoSuchElementException
textarea
has no @class
- it's an attribute of ancestor div
. Try below code instead:
eventDriver.findElement(By.cssSelector("div.CodeMirror textarea")).click();
or with ExplicitWait:
WebDriverWait wait = new WebDriverWait(eventDriver,10);
wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("div.CodeMirror textarea"))).click();
Update
WebElement element = eventDriver.findElement(By.cssSelector("div.CodeMirror textarea"))
JavascriptExecutor jse = ((JavascriptExecutor)eventDriver);
jse.executeScript("arguments[0].click()", element);