Selenium C# 4.0 版本说您可以隐藏命令提示符 - 您实际上是如何做到的?

软件测试 网络驱动程序
2022-02-04 22:12:57

我正在更新到 2.40 版并正在查看更改日志。http://selenium.googlecode.com/git/dotnet/CHANGELOG

它说“现在提供一个选项来隐藏 .NET 绑定中驱动程序服务可执行文件(IEDriverServer.exe、chromedriver.exe 等)的命令提示符窗口。”

我找不到要使用什么设置来实现这一点。我该怎么做?

2个回答

是的,您现在可以在 Selenium 2.40.0 中隐藏命令提示符窗口。我之前正在写一篇关于此的博客文章,您可能想在这里查看

请注意,不建议隐藏命令提示符窗口。

铬驱动程序

var driverService = ChromeDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;

var driver = new ChromeDriver(driverService, new ChromeOptions());

InternetExplorer驱动程序

var driverService = InternetExplorerDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;

var driver = new InternetExplorerDriver(driverService, new InternetExplorerOptions());

PhantomJSDriver

var driverService = PhantomJSDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;

var driver = new PhantomJSDriver(driverService);
ChromeDriverService chromeservice = ChromeDriverService.CreateDefaultService();
   chromeservice.HideCommandPromptWindow = true; //hide console window
   ChromeDriver driver = new ChromeDriver(chromeservice);

   FirefoxDriverService firefoxservice = FirefoxDriverService.CreateDefaultService();
   firefoxservice.HideCommandPromptWindow = true; //hide console window
   FirefoxDriver driver = new FirefoxDriver(firefoxservice);

其他几个Selenium工具