1

I have a C# Selenium WebDriver script that uses the AutoItX3Lib to attempt to perform a download of an excel file.

The script works up to the point when it clicks the link to start the download.

Relevant section of script copied below:

// Wait until "Contacts.xls" link displays
            WebDriverWait wait4 = new WebDriverWait(driver, TimeSpan.FromSeconds(300));
            wait4.Until(ExpectedConditions.ElementIsVisible(By.LinkText("contacts.xls")));

// Click "Contacts.xls"
driver.FindElement(By.LinkText("contacts.xls")).Click();

// Perform file download and saving using AutoIt
autoit.WinActivate("Opening contacts.xls","");
autoit.Send("{ALTDOWN}s{ALTUP}");
autoit.Sleep(3000);
autoit.Send("{ENTER}");

The problem is that at the first Send command (autoit.Send("{ALTDOWN}s{ALTUP}");) ,which should send the ALT + s keys to the Firefox file download dialog window, the script stops. However, instead of sending the keys to the Firefox file download dialog window, it sends the keys to Visual Studio (which is IDE that I am using to create and execute the script).

Thanks in Advance

user4157124
  • 2,809
  • 13
  • 27
  • 42
Kenito
  • 53
  • 2
  • 10

2 Answers2

0

There are two options that I can suggest:

  1. Create and execute AutoIt script's .exe file before clicking on download. You can get more details here.

  2. If you are only interested in Firefox, then better to configure & use Firefox profile that auto downloads file to desired location. You can refer this link to get details on Firefox profile preferences that you need to set.

Community
  • 1
  • 1
Surya
  • 4,446
  • 2
  • 17
  • 19
0

Try the following:

// Click "Contacts.xls"
driver.FindElement(By.LinkText("contacts.xls")).Click();
Thread.Sleep(2000)

I think the problem may be with waiting until the file download dialog window appears.