2009-10-09 19 views
0

J'avais l'habitude d'utiliser WatiN pour mon projet Web Automation. Mais, IE a semblé lent à moi. J'ai essayé d'utiliser WatiN avec des projets FF, mais il semble que WatiN avec Firefox n'est pas aussi puissant que WatiN avec IE. Avant cela, j'ai étudié comment utiliser WatiN dans Firefox 3.5. Parce que WatiN est livré avec jssh pour FF 2.x et FF 3.x. Quand j'utilise WatiN avec Jssh FF 3.x, FF se bloque. Donc, I found a topic in this site, il dit SWAT (Simple Web Automation Toolkit) a une version plus récente de jssh et compatible avec 3.5.Comment désactiver une sortie de console .DLL?

J'ai téléchargé SWAT et j'ai installé cette extension sur FF. Ça a vraiment marché! Mais il semble que WatiN ne peut pas ouvrir plusieurs pages FF à la fois et ne peut pas ouvrir la page FF lorsqu'une page FF est déjà ouverte. C'est très agaçant.

Alors, j'ai encore regardé SWAT. Il y a rarement du document C# pour SWAT mais le langage de script de SWAT est déjà presque le même que celui de C#. Tout va bien dans SWAT (n'est toujours pas aussi bon que WatiN avec IE, mais pour FF c'est mieux que WatiN).

J'aime les applications console plus que les GUI si je ne veux pas partager mon projet. J'ai donc créé une application console. J'ai écrit des codes etc ... J'ai couru mon projet, mais il semble que SWAT envoie une sortie de débogage ou une sortie console/print ou autre.

par exemple: Quand j'utilise ce code:

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

Je vois ce texte sur mon écran de la console:

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

Et il y a plus que cela.

Le code I écrit:

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

Sortie de la console:

(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 

Comment désactiver cette sortie? Je vais imprimer quelque chose à l'écran de la console et ils sont importants :).

Merci ...

Répondre