'Sendkeys does not work for uploading a folder in selenium c# in headless mode

The code is working fine in normal mode and it silently uploads the entire folder yet when executed in headless mode it does nothing. Just execute the line and move to the next line. I am using the following code:

//uploading file or folder silently
IWebElement selectFiles = driver.FindElement(By.XPath(xPath));
string path = buttonObject.TID.Contains("fileUpload") ? "\\InputFiles\\DMFiles" + fileName : "\\InputFiles\\DMFiles\\";
Logging.Logger.LogInfo("Path of file/folder is: "+ AppConfig.SolutionPath + path);
selectFiles.SendKeys(AppConfig.SolutionPath + path);
Thread.Sleep(Constants.ThreadSleep);

The image of the element is attached

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source