Hide/Silence ChromeDriver window

2019-02-05 06:17发布

When I launch Selenium's WebDriver (Chromedriver). A console window (chromedriver.exe) runs and it opens Chrome. I need to know how I can hide those like a silent mode because I get messy when there are too many open. I am using C#.

3条回答
兄弟一词,经得起流年.
2楼-- · 2019-02-05 06:29

To my knowledge it's not possible to hide the browser. However, you can hide the console and set the browser offscreen:

ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.HideCommandPromptWindow = true;

var options = new ChromeOptions();
options.AddArgument("--window-position=-32000,-32000");

var driver = new ChromeDriver(service, options);
driver.Navigate().GoToUrl("https://www.google.co.uk");
查看更多
小情绪 Triste *
3楼-- · 2019-02-05 06:34

As of Chrome 59, you can now also hide the chrome browser window by using headless mode:

options.AddArgument("headless");

and in combination with:

ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.HideCommandPromptWindow = true;

it runs in complete silence.

查看更多
你好瞎i
4楼-- · 2019-02-05 06:50

Hello chrome driver command hide coding

    public IWebDriver drv;
    public AnaSayfa()
    {
        CheckForIllegalCrossThreadCalls = false;
        ChromeDriverService service = ChromeDriverService.CreateDefaultService();
        service.HideCommandPromptWindow = true;
        drv = new ChromeDriver(service);
        InitializeComponent();
   }
    void BekraHayrNesterGo()
    {
      drv.Navigate().GoToUrl("https://www.example.com/");
    }

This shape can hide cmd

查看更多
登录 后发表回答