问题
I have a below code. after ds.Click();
one file will be downloaded to downloads folder, the file will be as a .ica extension.
IWebDriver cobj = new ChromeDriver();
cobj.Navigate().GoToUrl("https://XX.xxx.xx");
IWebElement u = cobj.FindElement(By.Name("login"));
IWebElement p = cobj.FindElement(By.Name("passwd"));
IWebElement b = cobj.FindElement(By.Id("Log_On"));
u.SendKeys("username");
p.SendKeys("password");
b.Click();
IWebElement d = cobj.FindElement(By.Id("folderLink_0"));
d.Click();
IWebElement ds = cobj.FindElement(By.Id("idCitrix.Production"));
ds.Click();
How to open that file?
回答1:
You can't open files with Selenium. Opening files is part of the operating system. Selenium only drives the browser, so after the file is downloaded Selenium is finished.
Some other tools to pick-up after Selenium has downloaded the file:
- AutoIt: Launching or running ica file with autoit script
- Sikuli: https://hellotestworld.com/2012/04/27/sikuli-for-all-those-hard-to-reach-places/
- Coded-UI: https://msdn.microsoft.com/en-us/library/dd286726.aspx?f=255&MSPPError=-2147217396
Automating Citrix is also not possible with Selenium.
- Can we automate Application available under Citrix Program Neighbourhood?
回答2:
If you want to open in it in the browser, you can use something like that:
cobj.Navigate().GoToUrl("file:///C:/Users/yourUserName/Downloads/image004.jpg");
Just change the file type and so on.
来源:https://stackoverflow.com/questions/42415263/how-to-open-a-ica-downloaded-file-from-selenium-c-sharp