0

I tried pasting a file path using all the below, but no luck. I know there`re no ways but I wanted to give it a shot though. Kindly let me know if theres still a way.

//Code

ClickbrowseButton.Click(); //Opens up a windows pop-up
string _filePath = "C:\Temp\Testdatafile.txt";

I tried using all the below ones.

  • InputSimulator - doesn`t seem to support .net core, was getting a warning.
  • AutoIt - can't use as we'll be running it on servers and this should be installed on the servers too.
  • Robot - No good reviews about this.
  • SendKeys - cant use library - System.Windows.Forms, as the git runner is running on linux.
  • IJavascriptExecutor - doesn`t work as it takes webdriver.

So can someone suggest a way to paste file path apart from the above ones. Thanks!

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236
DeSon
  • 147
  • 13
  • What did you actually try? Selenium uses WebDriver and [IWebElement.SendKeys](https://www.selenium.dev/selenium/docs/api/dotnet/html/M_OpenQA_Selenium_IWebElement_SendKeys.htm) has nothing to do with Windows Forms. Post the actual code you used. The thing you tried are unclear - there's no "Robot" or "AutoIt" in Selenium (AutoIt is an application), no need for WinForms, and Selenium wouldn't work without WebDriver anyway – Panagiotis Kanavos May 06 '21 at 08:24
  • Post the code you used *and* the relevant HTML. There's no `ClickbrowseButton` in Selenium. Is this an IWebElement? What element does it point to ? An `input type="file"`? Something else? If it's an `input`, have you tried `ClickbrowseButton.SendKeys(_filePath);` ? – Panagiotis Kanavos May 06 '21 at 11:40
  • Have you checked [this possibly duplicate question](https://stackoverflow.com/questions/65929809/how-to-handle-a-window-file-upload-pop-up-in-selenium-c-sharp)? If there's a single upload input you can use `driver.FindElement(By.XPath("//input[@type='file']")).SendKeys(filePath);` – Panagiotis Kanavos May 06 '21 at 11:58

0 Answers0