How to handle File download dialog/popup in IE browser USING SELENIUM and C#
AutoItX3 autoit = new AutoItX3(); autoit.WinActivate("Save"); Thread.Sleep(1000); autoit.Send("{F6}"); Thread.Sleep(1000); autoit.Send("{TAB}"); Thread.Sleep(1000); autoit.Send("{ENTER}");
You can try this code.
using System;using Microsoft.VisualStudio.TestTools.UnitTesting;using OpenQA.Selenium;using OpenQA.Selenium.IE; using OpenQA.Selenium.Support.UI;using System.Threading;using System.Collections.Generic;using System.Windows.Forms;//using NUnit.Framework;namespace SampleTest{ [TestMethod] public void Download() { IWebDriver driver = new InternetExplorerDriver(@"C:\Users\hamit\Desktop\Selenium\IEDriverServer_Win32_2.48.0"); driver.Navigate().GoToUrl("https://www.spotify.com/se/download/windows/"); Thread.Sleep(2000); SendKeys.SendWait("@{TAB}"); Thread.Sleep(100); SendKeys.SendWait("@{TAB}"); Thread.Sleep(100); SendKeys.SendWait("@{DOWN}"); Thread.Sleep(100); SendKeys.SendWait("@{DOWN}"); Thread.Sleep(100); SendKeys.SendWait("@{Enter}"); }}
like an option - try get all exist buttons and then filter by inner text
var posibleButtons = driver.FindElements(By.TagName("button")).Where(el => el.Text.Contains("Open"));posibleButtons.Where(// try use some other filters, maybe by styles or ets...