如何处理IE浏览器中的文件下载对话框/弹出窗口使用SELENIUM和C# [英] How to handle File download dialog/popup in IE browser USING SELENIUM and C#
本文介绍了如何处理IE浏览器中的文件下载对话框/弹出窗口使用SELENIUM和C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
你可以试试这个代码。
using System;
使用Microsoft.VisualStudio.TestTools.UnitTesting;
使用OpenQA.Selenium;
使用OpenQA.Selenium.IE;
使用OpenQA.Selenium.Support.UI;
使用System.Threading;
using System.Collections.Generic;
使用System.Windows.Forms;
//使用NUnit.Framework;
命名空间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});
}
}
I have page which downloads a file which shows a dialog on the bottom with OPEN SAVE CANCEL options, how can I click those options ? I am using IE browser, I saw some solutions using third party AutoIt, Robot class, but I am looking with Selenium and C# only. Attached is the image of what I am talking.. Any idea how can we do this ?
解决方案
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}");
}
}
这篇关于如何处理IE浏览器中的文件下载对话框/弹出窗口使用SELENIUM和C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文