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 的 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

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

谢谢...

4

1 回答 1

0

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

于 2009-10-09T09:17:41.517 回答