简体   繁体   English

隐藏 geckodriver 命令窗口 selenium c#

[英]Hide geckodriver command window selenium c#

I have a windows form application.我有一个 Windows 窗体应用程序。 Running the project which contains selenium (geckodriver) it is opening a Command Window .运行包含 selenium (geckodriver) 的项目,它会打开一个Command Window How can I hide it?我怎样才能隐藏它?

enter image description here在此处输入图片说明

Below I attached my code:下面我附上了我的代码:

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

you can hide the command prompt window now in Selenium 2.40.0.您现在可以在 Selenium 2.40.0 中隐藏命令提示符窗口。 this a blog article about this earlier, which you might want to have a look here这是之前关于此的博客文章,您可能想在此处查看

I have adapted the code from here and it worked.我已经修改了这里的代码并且它起作用了。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM