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

发布于 2024-08-07 17:11:16 字数 5138 浏览 3 评论 0原文

我曾经在我的 Web 自动化项目中使用 WatiN。但是,IE 对我来说看起来很慢。我尝试在 FF 项目中使用 WatiN,但似乎 Firefox 中的 WatiN 不如 IE 中的 WatiN 强大。

在我想到这一点之前,我研究了如何在 Firefox 3.5 中使用 WatiN。因为 WatiN 附带了 FF 2.x 和 FF 3.x 的 jssh。当我将 WatiN 与 Jssh FF 3.x 一起使用时,FF 崩溃。所以,我在此找到了一个主题网站,它说 SWAT (Simple Web Automation Toolkit) 有更新版本的 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

如何禁用此输出?我将在控制台屏幕上打印一些内容,它们很重要:)。

谢谢...

I used to use WatiN for my Web Automation project. But, IE looked slow to me. I tried to use WatiN with FF projects, but it seems WatiN with Firefox is not as powerful as WatiN with IE.

Before I though this, I researched how to use WatiN in Firefox 3.5. Because WatiN comes with jssh for FF 2.x and FF 3.x. When I use WatiN with Jssh FF 3.x, FF crashes. So, I found a topic in this site, it says SWAT (Simple Web Automation Toolkit) has a newer version of jssh and compatible with 3.5.

I downloaded SWAT and installed that extension to FF. It really worked! But it seems, WatiN can't open multiple FF pages at once and can't open FF page when a FF page is already open. This is very annoying.

So, I looked to SWAT again. There are rarely C# document for SWAT but, SWAT's scripting language is already almost the same as C#'s. Everything looks good in SWAT (still is not as good as WatiN with IE, but for FF it's better than WatiN).

I like console apps more than GUI's if I will not share my project. So, I created a console application. Wrote codes etc... I ran my project, but it seems SWAT sends a debug output or console output/print or whatever.

for example: When I use this code:

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

I see this text on my console screen:

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

And there are more than this.

The code I written:

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

Console output:

(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

How to disable this output? I will print somethings to the console screen and they are important :).

Thanks...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一张白纸 2024-08-14 17:11:16

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

Perhaps you can just change the logging options. Found http://lists.samba.org/archive/samba/1998-December/010046.html message showing it can be controlled.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文