硒的webdriver PhantomJS C#总是打开一个cmd窗口 [英] Selenium Webdriver PhantomJS C# always opens a cmd window

查看:3775
本文介绍了硒的webdriver PhantomJS C#总是打开一个cmd窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用硒的webdriver PhantomJS在C#。以下是我的code:

I am trying to use PhantomJS with Selenium Webdriver in C#. Following is my code:

IWebDriver driver = new PhantomJSDriver();
driver.Navigate().GoToUrl("http://www.google.com");
Console.WriteLine(driver.Url);
driver.Quit();

在code正常工作,但每当它运行时,它开辟了其中显示phantomjs的所有日志一个cmd窗口。在CMD也被关闭与 driver.Quit()

的问题是,我不想显示命令窗口。我应该怎么做才能实现这一目标?

The problem is that I do not want the cmd window to be displayed. What should I do to achieve this?

更新:
当我做在Python同一code,cmd窗口不显示。但是,如果我转换python脚本使用py2exe到exe,在CMD窗口开始变得再次显示。

Update: When I do the same code in Python, the cmd window does not show up. But if I convert the python script to exe using py2exe, the cmd windows starts getting displayed again.

推荐答案

没有,有没有办法隐藏PhantomJS.exe在.NET绑定控制台窗口,而无需修改绑定的源$ C ​​$ C。这被看作是绑定的功能,因为它可以很容易地看到,当你code没有正确清理PhantomJSDriver的资源,因为控制台窗口保持打开状态。在其他一些语言的情况下,如果你的code不正确地调用对象的webdriver的退出()方法清理PhantomJSDriver的实例,你可以用一个僵尸PhantomJS.exe过程结束你的机器上运行

No, there is no way to hide the console window of the PhantomJS.exe in the .NET bindings without modifying the bindings source code. This is seen as a feature of the bindings, as it makes it very easy to see when your code hasn't correctly cleaned up the resources of the PhantomJSDriver, since the console window remains open. In the case of some other languages, if your code does not properly clean up the instance of PhantomJSDriver by calling the quit() method on the WebDriver object, you can end up with a zombie PhantomJS.exe process running on your machine.

这篇关于硒的webdriver PhantomJS C#总是打开一个cmd窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆