0

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-

simond
  • 684
  • 1
  • 10
  • 36

1 Answers1

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