IE在私有模式下使用Selenium C# [英] IE in Private Mode using Selenium C#

查看:68
本文介绍了IE在私有模式下使用Selenium C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在专用模式下打开IE来运行测试用例集.浏览器未打开.错误显示为

I want to open IE in Private mode to run the set of test cases. The browser is not opening. It shows error as

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.

Also I have changed the TabProcGrowth as 0 in Registry Editor.

如何在私有模式下打开IE来运行测试用例?我想在代码中进行任何更新.预先感谢.

How to open IE in private mode to run the test case? Anything I want to update in my code. Thanks in advance.

推荐答案

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

This is how I manage to launch it:

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

项目:解决方案资源管理器视图

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/");
        }
    }
}

这篇关于IE在私有模式下使用Selenium C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆