如何禁用.DLL的控制台输出?

时间:2009-10-09 07:16:10

标签: c# firefox watin console-output

我曾经在我的Web Automation项目中使用WatiN。但是,IE看起来很慢。我尝试将WatiN与FF项目一起使用,但似乎WatiN与Firefox不如WatiN与IE一样强大。

在此之前,我研究了如何在Firefox 3.5中使用WatiN。因为WatiN带有FF 2.x和FF 3.x的jssh。当我使用WatiN和Jssh FF 3.x时,FF崩溃了。所以,I found a topic in this site,它说SWAT(简单Web自动化工具包)有一个更新版本的jssh并与3.5兼容。

我下载了SWAT并将该扩展程序安装到FF。它真的有用!但看起来,WatiN无法一次打开多个FF页面,并且当FF页面已经打开时无法打开FF页面。这非常烦人。

所以,我再次看向SWAT。 SWAT很少有C#文档,但SWAT的脚本语言已经和C#几乎相同了。 SWAT中的一切看起来都不错(仍然不如使用IE的WatiN,但对于FF来说它比WatiN更好)。

如果我不共享我的项目,我更喜欢控制台应用程序而不是GUI。所以,我创建了一个控制台应用程序写代码等...我运行了我的项目,但似乎SWAT发送调试输出或控制台输出/打印或其他。

例如:当我使用此代码时:

var ff = new WebBrowser(BrowserType.FireFox);`

我在控制台屏幕上看到了这个文字:

(09.10.2009 09:57:09, 0) - Firefox browser initialized... 

还有更多。

我写的代码:

var ff = new WebBrowser(BrowserType.FireFox);
ff.OpenBrowser();
ff.NavigateBrowser("www.google.com.tr");
ff.SetElementAttribute(IdentifierType.Name,
     "btnG","value","Search with Google!");

控制台输出:

(09.10.2009 10:04:56, 0) - Firefox browser initialized...
(09.10.2009 10:04:56, 0) - Starting firefox process..
(09.10.2009 10:04:56, 0) - Found firefox window, attempting to establish connect
ion..
(09.10.2009 10:04:58, 0) - Connected, attempting to attach to browser
(09.10.2009 10:04:58, 0) - Attempting to attach to window about:config
(09.10.2009 10:04:58, 0) - Send: indexCount = 0;window = null;i = 0;for(i = 0;i
< getWindows().length;i++){var windowTitle = getWindows()[i].document.title.toLo
werCase(); if(windowTitle.indexOf('about:config') > -1){if(indexCount ==0){windo
w = getWindows()[i];break;}else indexCount++;}}
(09.10.2009 10:04:58, 0) - Received: Welcome to the Mozilla JavaScript Shell!
(09.10.2009 10:04:58, 0) - Send: window
(09.10.2009 10:04:58, 0) - Received: [object ChromeWindow]
(09.10.2009 10:04:58, 0) - Send: var browser = window.getBrowser();print(window.
document.title);
(09.10.2009 10:04:58, 0) - Received: [object ChromeWindow]
(09.10.2009 10:04:58, 0) - Send: var browser = window.getBrowser();print(window.
document.title);
(09.10.2009 10:04:58, 0) - Received: about:config - Mozilla Firefox
(09.10.2009 10:04:58, 0) - Send: browser.loadURI("www.google.com.tr");print('OK'
);
(09.10.2009 10:04:58, 0) - Received: about:config - Mozilla Firefox
(09.10.2009 10:04:58, 0) - Send: browser.webProgress.busyFlags
(09.10.2009 10:04:58, 0) - Received: OK
(09.10.2009 10:04:58, 0) - Send: browser.webProgress.busyFlags
(09.10.2009 10:04:58, 0) - Received: 3
(09.10.2009 10:04:59, 0) - Send: browser.webProgress.busyFlags
(09.10.2009 10:04:59, 0) - Received: 5
(09.10.2009 10:04:59, 0) - Send: browser.webProgress.busyFlags
(09.10.2009 10:04:59, 0) - Received: 5
(09.10.2009 10:04:59, 0) - Send: browser.webProgress.busyFlags
(09.10.2009 10:04:59, 0) - Received: 5
(09.10.2009 10:05:00, 0) - Send: browser.webProgress.busyFlags
(09.10.2009 10:05:00, 0) - Received: 0
(09.10.2009 10:05:00, 0) - Send: print(window.document.title)
(09.10.2009 10:05:00, 0) - Received: Google - Mozilla Firefox
(09.10.2009 10:05:00, 0) - Send: print(browser.currentURI.spec)
(09.10.2009 10:05:00, 0) - Received: http://www.google.com.tr/
(09.10.2009 10:05:00, 0) - Send: var doc = browser.contentDocument;print('OK')
(09.10.2009 10:05:00, 0) - Received: OK
(09.10.2009 10:05:00, 0) - Send: browser.webProgress.busyFlags
(09.10.2009 10:05:01, 0) - Received: 0
(09.10.2009 10:05:01, 0) - Send: print(window.document.title)
(09.10.2009 10:05:01, 0) - Received: Google - Mozilla Firefox
(09.10.2009 10:05:01, 0) - Send: print(browser.currentURI.spec)
(09.10.2009 10:05:01, 0) - Received: http://www.google.com.tr/
(09.10.2009 10:05:01, 0) - Send: var doc = browser.contentDocument;print('OK')
(09.10.2009 10:05:01, 0) - Received: OK
(09.10.2009 10:05:01, 0) - Send: var elem = null;elem = doc.getElementsByName('b
tnG')[0];if(elem == null){for(i =0;i < doc.getElementsByTagName('iframe').length
;i++){ if(doc.getElementsByTagName('iframe')[i].contentDocument.getElementsByNam
e('btnG')[0]!=null){elem = doc.getElementsByTagName('iframe')[i].contentDocument
.getElementsByName('btnG')[0]; break;}}}if(elem == null){for(i =0;i < doc.getEle
mentsByTagName('frame').length;i++){ if(doc.getElementsByTagName('frame')[i].con
tentDocument.getElementsByName('btnG')[0]!=null){elem = doc.getElementsByTagName
('frame')[i].contentDocument.getElementsByName('btnG')[0]; break;}}}var origColo
r = '';if(elem != null){origColor = elem.style.backgroundColor;if(origColor == n
ull)origColor = '';elem.style.backgroundColor = 'yellow';}if(elem != null){ elem
.value = 'Search with Google!';print('OK');}else{ print('failed');}
(09.10.2009 10:05:02, 0) - Received: OK
(09.10.2009 10:05:02, 0) - Send: if(elem != null){elem.style.backgroundColor = o
rigColor;elem = null;};print('OK')
(09.10.2009 10:05:02, 0) - Received: OK

如何禁用此输出?我会将一些东西打印到控制台屏幕,它们很重要:)。

...谢谢

1 个答案:

答案 0 :(得分:0)

也许您只需更改日志记录选项即可。找到显示可以控制的http://lists.samba.org/archive/samba/1998-December/010046.html消息。