0

I'm trying to comment in Instagram post by using selenium (java). Instagram Comment box in textArea, How can I add comment?
I did this...

WebElement cmdbox = driver.findElement(By.tagName("textarea"));
cmdbox.clear();
Thread.sleep(2000);
cmdbox.sendKeys("sample text");
Thread.sleep(3000);

I got this error

error image

Bashir
  • 2,057
  • 5
  • 19
  • 44
Sachin
  • 11
  • 5

2 Answers2

0

ElementNotInteractableException is Thrown to indicate that although an element is present on the DOM, it is not in a state that can be interacted with.

aka it is in the DOM but you cannot click on it yet. There are a few ways to solve this using ExpectedConditions.elementToBeClickable() is one way. A helper method could help before calling click.

 public static void waitForElementClickable(WebDriver webdriver, By by, long timeout) {
    WebDriverWait wait = new WebDriverWait(webdriver, timeout);
    wait.until(ExpectedConditions.elementToBeClickable(by));
  }
redx
  • 59
  • 4
0
WebDriverWait wait = new WebDriverWait(webdriver, timeout); //15 can be ideal for timeout

//the code to clear area

wait.until(ExpectedConditions.elementToBeClickable(By.tagName("textarea"))).clear();

//the code to sendKeys

wait.until(ExpectedConditions.visibilityOfElementLocated(By.tagName("textarea"))).sendKeys("sample text");

if this does not work, you can use By.CssSelector("textarea.Ypffh") as another alternative to the By.tagName("textarea")

Hacci56
  • 39
  • 5