如何使用SELENIUM和C#在IE浏览器中处理打开或保存对话框/弹出窗口

问题描述 投票:0回答:1

我有一个测试用例,将行数导出到xls / CSV文件中,然后使用基准版本验证数据。对于chrome浏览器,它可以按预期工作,但是在IE 11中,每次尝试导出到excel时,我都会收到以下给定的通知。我尝试了以下选项,但没有运气

  • 使用Action类发送Alt + s键
  • 发送Tab键,然后输入
  • 试图在“安全性”选项卡中查找选项以禁用弹出通知但找不到)>
  • **enter image description here**

请有人可以帮忙吗?

我有一个测试用例,将行数导出到xls / CSV文件中,然后使用基准版本验证数据。对于chrome浏览器,它可以按预期工作,但是在IE 11中,我得到的是......]

selenium internet-explorer-11
1个回答
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}");
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.