msb*_*uva 8 selenium internet-explorer file download
我有一个页面下载一个文件,该文件在底部显示一个对话框,带有OPEN SAVE CANCEL选项,如何点击这些选项?我使用IE浏览器,我看到了一些使用第三方AutoIt,Robot类的解决方案,但我只看Selenium和C#.附上我正在谈论的形象..任何想法我们怎么能这样做?
小智 0
你可以试试这个代码。
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}");
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7469 次 |
| 最近记录: |