首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >C#自动化边缘浏览器-使用边缘驱动程序-自动测试程序-故障:找不到匹配的功能(SessionNotCreated)

C#自动化边缘浏览器-使用边缘驱动程序-自动测试程序-故障:找不到匹配的功能(SessionNotCreated)
EN

Stack Overflow用户
提问于 2021-11-22 07:54:22
回答 1查看 96关注 0票数 0

欢迎stackoverflow社区,

我正在尝试编译和运行这个网站上的程序代码:

https://social.msdn.microsoft.com/Forums/en-US/7bdafd2a-be91-4f4f-a33d-6bea2f889e09/c-sample-for-automating-ms-edge-chromium-browser-using-edge-web-driver

我按照链接中列出的所有说明设置了我想要的路径。

程序和边缘驱动程序开始运行,但随后出现错误。

WebDriver.dll中出现错误异常"System.InvalidOperationException“。

进一步信息:未创建会话:找不到匹配的功能(SessionNotCreated)“

这是我的程序中的代码,或多或少是从上面的链接复制的:

代码语言:javascript
运行
复制
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.UI;

namespace ConsoleApplication2
{
class Program
{
    static void Main(string[] args)
    {
        var anaheimService = ChromeDriverService.CreateDefaultService(@"C:\edgedriver_win64", "msedgedriver.exe"); 
           // user need to pass the driver path here....
           var anaheimOptions = new ChromeOptions
           {
               // user need to pass the location of new edge app here....
               BinaryLocation = @"
        C: \Program Files(x86)\Microsoft\Edge\Application\msedge.exe "
           };

        IWebDriver driver = new ChromeDriver(anaheimService, anaheimOptions); -- error appears at this line
        driver.Navigate().GoToUrl("https: //google.com/");
        Console.WriteLine(driver.Title.ToString());
        driver.Close();
     }
   }
}

我真的很感谢你的帮助!

最好的问候Max

EN

Stack Overflow用户

发布于 2021-11-23 02:40:54

你提到的那篇文章有点过时了。现在我们不需要使用ChromeDriver来自动化边缘。有关如何使用WebDriver自动化Microsoft Edge的信息,请参阅official doc

我推荐使用Selenium 4,这里我安装了Selenium 4.1.0 NuGet包,示例C#代码如下:

代码语言:javascript
运行
复制
using System;
using OpenQA.Selenium.Edge;

namespace WebDriverTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var options = new EdgeOptions();
            options.BinaryLocation = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe";    
            var driver = new EdgeDriver(@"C:\edgedriver_win64", options);

            driver.Navigate().GoToUrl("https://www.google.com");
            Console.WriteLine(driver.Title.ToString());
            driver.Close();
        }
    }
}
票数 1
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70062505

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档