【问题标题】:Is there a way to open HTTP web in Edge using selenium and iedriver?有没有办法使用 selenium 和 iedriver 在 Edge 中打开 HTTP Web?
【发布时间】:2022-06-18 01:56:15
【问题描述】:

所以我正在使用此代码,但如果 Web 是 HTTP,它会在 IE 而不是 Edge 上打开。

var ieOptions = new InternetExplorerOptions();
        ieOptions.EdgeExecutablePath = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe";
        IWebDriver driver = new InternetExplorerDriver(ieOptions);

        driver.Url = "some http web";

有没有办法强制它在边缘?

【问题讨论】:

    标签: c# selenium selenium-iedriver iedriverserver


    【解决方案1】:

    您需要download Microsoft Edge Driver 并使用它。您的代码当前使用的类的名称应该可以提示您打开 Internet Explorer 的原因:

    IWebDriver driver = new InternetExplorerDriver(ieOptions);
                            ^^^^^^^^^^^^^^^^
    

    名字就对了:InternetExplorerDriver。您正在使用 Internet Explorer 的 Web 驱动程序。如果你想自动化 Edge,你需要使用 EdgeDriver。

    我认为奇怪的是,在使用 InternetExplorerDriver 时加载 HTTPS URL 时会启动 Edge。我怀疑安装了覆盖 Internet Explorer 的 Windows 策略,导致 Edge 被启动。

    【讨论】:

      【解决方案2】:

      创建InternetExplorerDriver 并传递这个InternetExplorerOptions

      var options = new InternetExplorerOptions
      {
          AttachToEdgeChrome = true,
          EdgeExecutablePath = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
      };
      
      var driver = new InternetExplorerDriver(ieOptions);
      driver.Url = "https://example.com";
      

      【讨论】:

        猜你喜欢
        • 2021-08-31
        • 1970-01-01
        • 1970-01-01
        • 2019-04-26
        • 1970-01-01
        • 2012-11-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多