【问题标题】:Hide geckodriver command window selenium c#隐藏 geckodriver 命令窗口 selenium c#
【发布时间】:2020-02-07 13:27:08
【问题描述】:

我有一个 Windows 窗体应用程序。运行包含 selenium (geckodriver) 的项目,它正在打开一个Command Window。怎么隐藏?

enter image description here

下面我附上了我的代码:

public partial class Form1 : Form
    {
        IWebDriver driver = new FirefoxDriver();
        public Form1()
        {
            InitializeComponent();     
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            driver.Navigate().GoToUrl("https://www.google.com");
        }
}

【问题讨论】:

    标签: c# selenium selenium-webdriver webdriver geckodriver


    【解决方案1】:

    您现在可以在 Selenium 2.40.0 中隐藏命令提示符窗口。这是之前的一篇博客文章,你可能想看看here

    【讨论】:

    • 我尝试过类似的方法,但没有成功。
    • 我无法创建变量var 而不是IWebDriver
    【解决方案2】:

    我已经修改了here 中的代码并且它有效。

    public partial class Form1 : Form
        {
            IWebDriver driver;
            public Form1()
            {
                InitializeComponent();     
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                ar driverService = FirefoxDriverService.CreateDefaultService();
                driverService.HideCommandPromptWindow = true;
                driver = new FirefoxDriver(driverService, new FirefoxOptions());
                driver.Navigate().GoToUrl("https://www.google.com");
            }
    }
    

    【讨论】:

      猜你喜欢
      • 2022-11-23
      • 1970-01-01
      • 2015-12-27
      • 1970-01-01
      • 1970-01-01
      • 2018-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多