I am running selenium webdriver automation in c# for chrome browser. Here i have requirement - i have to save pdf document/html page. so what i am doing is ..right clicking and then trying to move till "Save as" but its not working. I have used below code for that-
Asked
Active
Viewed 1,131 times
0
-
Please define "Not working". Any errors? Also, post the complete code you have at the moment. – alecxe Jul 29 '15 at 13:51
-
Selenium cannot interact with system windows and prompts, only with web pages! – SiKing Jul 29 '15 at 14:47
-
i am not getting any error from above code but "document is not getting saved" . – simond Jul 31 '15 at 05:34
1 Answers
0
As in the comments mentioned, Selenium Webdriver can't send keys to the file dialog itself. But with the following code you can send this to the active window, in your example Chrome:
using System.Windows.Forms;
SendKeys.SendWait("^s"); // send control+s
Thread.Sleep(1000);
SendKeys.SendWait("fileName{ENTER}"); // sends "fileName then enter
The Thread.Sleep is for the fact that chrome has time to open the filesave dialog. Be careful this code can't change the location.

LzyPanda
- 723
- 6
- 11