When I attempt to input text using JavascriptExecutor
, the code snippet below is what I use:
private void inputWorkDescription(WebDriver driver, int rawNumber) throws IOException, GeneralSecurityException {
if (!getWorkDescriptionFromSheets(rawNumber).isEmpty()) {
WebDriverWait wait = new WebDriverWait(driver, WAITING_PERIOD);
WebElement workDescription = wait.until(ExpectedConditions.visibilityOfElementLocated(
By.cssSelector("span.placeholder-decoration.ProseMirror-widget span")));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", workDescription); // ---WORKS
executor.executeScript("arguments[0].value='123456';", workDescription); // --- DOESN'T WORK
executor.executeScript("arguments[0].setAttribute('value', '"
+ getWorkDescriptionFromSheets(rawNumber) + "');", workDescription); // --- DOESN'T WORK
}
}
Unfortunately, this method doesn't seem to be functioning correctly. Despite seeing that the click
command is executed successfully, I am unable to input any text.
I have tried various approaches for text input, but none of them seem to work.