Я хотел бы посмотреть, возможно ли передать FileStream (вместо файла) в HTML-ввод, используя Selenium.
Сценарий заключается в том, что мне нужно автоматизировать загрузку файлов, но эти файлы никогда не следует сохранять на машине, поэтому используется массив байтов.
Я не могу использовать http-запрос из-за сложной аутентификации WebPortal. Именно поэтому используется Chrome WebDriver.
private Tuple<bool, string> UploadFile(string fileName, byte[] fileContentClear, Customer destCustomer)
{
//chrome definition
//Selenium login into the portal and opening the Html File browser
//Select and submit file
string theFilePath = file.Replace('/', '\\'); //need to put backslash the filepath, else will fail
browser.FindElement(By.XPath(GetFileBtnXpath)).SendKeys(file); //insert the path in input box
//file will be a byteArray
IWebElement uploadAndSubmitButton = browser.FindElement(By.XPath(uploadSubmitBtnXpath));
uploadAndSubmitButton.Click(); //submit the file
}