【问题标题】:IE in Private Mode using Selenium C#使用 Selenium C# 在私有模式下的 IE
【发布时间】:2021-05-19 09:46:55
【问题描述】:

我想以私有模式打开 IE 来运行这组测试用例。浏览器打不开。它显示错误为

The HTTP request to the remote WebDriver server for URL {URL} timed out after 60 seconds

示例代码:

InternetExplorerOptions options = new InternetExplorerOptions()
{
    ForceCreateProcessApi = true,
    BrowserCommandLineArguments = "-private",
};
IWebDriver driver = new InternetExplorerDriver("C:\\Reports", options);

driver.Navigate().GoToUrl("https://www.google.com");

我还在注册表编辑器中将 TabProcGrowth 更改为 0。

如何以私有模式打开IE运行测试用例?我想在我的代码中更新的任何内容。提前致谢。

【问题讨论】:

  • 尝试将PageLoadStrategy = PageLoadStrategy.Eager 添加到options 并再次尝试运行您的代码。看看有没有区别。如果问题仍然存在,我建议您告知我们您用于进行此测试的 IE 浏览器、Web 驱动程序和 selenium 的确切版本?

标签: c# selenium selenium-webdriver internet-explorer private


【解决方案1】:

这就是我设法启动它的方式:

  1. 在注册表编辑器中将 TabProcGrowth 设置为 0。
  2. 获取 Selenium.WebDriver.IEDriver64 块而不是普通的 32 并构建项目
  3. 从 bin\Debug\netcoreapp3.1 获取 IEDriverServer64.exe(生成此文件的输出文件夹取决于您的 TargetFramework:.netcore 或 .netstandard)
  4. 将该文件重命名为 IEDriverServer.exe 并将其放在文件夹中的某个位置
  5. 使用该文件夹的路径创建驱动程序实例。就我而言,我在项目中创建了一个文件夹并指向那里

Project: Solution Explorer View

using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using System.IO;

namespace InternetExplorerPrivate
{
    public class Tests
    {
        public IWebDriver driver;

        [SetUp]
        public void Setup()
        {
            InternetExplorerOptions options = new InternetExplorerOptions();
            options.ForceCreateProcessApi = true;
            options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
            options.BrowserCommandLineArguments = "-private";
            driver = new InternetExplorerDriver(Path.GetFullPath(@"..\..\..\IEDriver"), options); 
        }

        [Test]
        public void Test1()
        {
            driver.Navigate().GoToUrl("https://stackoverflow.com/");
        }
    }
}

【讨论】:

猜你喜欢
  • 2021-05-15
  • 1970-01-01
  • 2019-04-23
  • 1970-01-01
  • 1970-01-01
  • 2015-02-10
  • 2020-05-17
  • 2015-08-01
  • 1970-01-01
相关资源
最近更新 更多