【问题标题】:Using Extensions in firefox selenium在 Firefox selenium 中使用扩展
【发布时间】:2021-11-02 18:54:27
【问题描述】:

我正在尝试在 selenium 中为 geckdriver 使用扩展,发现我需要使用 FirefoxProfile。不过,从这里开始,我不知道该怎么做。我在网上找不到太多帮助。这是我所拥有的,但我收到 System.TypeInitializationException 错误。

            FirefoxOptions options = new FirefoxOptions();

            FirefoxProfile profile = new FirefoxProfile();

            string workingDirectory1 = Environment.CurrentDirectory;

            profile.AddExtension(workingDirectory1 + "\\anticaptcha.xpi");

            options.Profile = profile;
           
            IWebDriver driver = new FirefoxDriver(options);

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

【问题讨论】:

    标签: c# selenium firefox


    【解决方案1】:

    看起来 addExtension 方法需要一些更正它接受 File 作为参数而不是字符串

    【讨论】:

      猜你喜欢
      • 2016-01-16
      • 1970-01-01
      • 2018-10-25
      • 1970-01-01
      • 2011-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多