0

I am running the below code snippet in Firefox Browser:

WebElement uploadControl = driver.findElement(By.cssSelector("input[type='file']"));
String file = "C:\\other\\abc.jpg";
uploadControl.sendKeys(file);

To note the Webelement is actually inside a shadow dom which I am fetching using JavascriptExecutor and storing it as 'uploadControl'.

When executing this code in Firefox browser, it gives error:

Org.openqa.selenium.ElementNotInteractableException: Element <input typ="file"> is not reachable by keyboard.

I tried to use JavascriptExecutor in place of sendKeys but it does not work.

Note: I already saw this question: org.openqa.selenium.ElementNotInteractableException: Element is not reachable by keyboard: while sending text to FirstName field in Facebook as well and tried different solutions but nothing works.

shivam
  • 249
  • 1
  • 5
  • 18
  • _Webelement is actually inside a shadow dom_: is possibly the root cause of all the mess around. See: [this](https://stackoverflow.com/a/55763793/7429447), [this](https://stackoverflow.com/a/73242476/7429447) and [this discussion](https://stackoverflow.com/q/56380091/7429447) – undetected Selenium Jul 27 '23 at 22:51

0 Answers0