一、概述 :
主函数 : frmMain.cs
事件的处理的函数 : WatinScript.cs
参数配置函数 : AppSettings.cs
生成脚本的接口函数 : CodeGenerator.cs
生成脚本的具体函数 : 封装在 Formatters 中
获取 Web 页面函数 : WebPage.cs
线程函数接口 : RunThreaded.cs
Excel 格式处理函数 : ExcelWriter.cs , ExcelReader.cs
列表封装函数 : ActionList.cs
具体的动作 : 封装在 actons 中各子类中,基类为 ActionsBase
二、具体事件 :
1 、 address 接受的事件 :
address 接受键盘 keyup 事件,调用方法名 comboURL_KeyUp( 在 frmMain.cs 中 ) ,调用方法 NavToUrl( string sUrl) , NavToUrl 调用 (CurWB .Navigate (sUrl )) ,下载网页到 csEXWB 控件,调用 (wscript .AddNavigation (watinie , sUrl , "" , "" )) , AddNavigation 函数调用记录操作的接口函数 AddAction
根据是否录制 (Recording, ShouldInsertActions) 标识判断是否将操作加入列表 (ActiveTest) ,
private void comboURL_KeyUp (object sender , KeyEventArgs e )
{
try
{
if (e .KeyCode == Keys .Return )
{
e .Handled = true ;
NavToUrl (comboURL .Text );
// wscript.SaveXML("e://test.xml");
}
else if (e .Control && e .KeyCode == Keys .V )
{
e .Handled = true ;
comboURL .Text = Clipboard .GetText ();
NavToUrl (Clipboard .GetText ());
cEXWB1 .Focus ();
}
else if (e .Control && e .KeyCode == Keys .C )
{
Clipboard .SetText (comboURL .Text );
}
}
catch (Exception eex )
{
MessageBox .Show (eex .Message , "comboUrl_KeyUp" );
}
}
public void NavToUrl (string sUrl )
{
if (!CheckWBPointer ())
return ;
try
{
CurWB .Navigate (sUrl );
wscript .AddNavigation (watinie , sUrl , "" , "" );
}
catch (Exception ee )
{
AllForms .FrmLog .AppendToLog ("NavToUrl/r/n" + ee );
}
}
public void AddNavigation (BrowserWindow browser , string url , string username , string password )
{
var nav = new ActionNavigate
{
ParentPage = browser .DeterminePage ();
URL = url ;
Username = username ;
Password = password;
};
if (WebPageList .FindByHash (nav .ParentPage .HashCode )==null )
{
WebPageList .Add (nav .ParentPage );
}
// if the username is not blank , replace a navigation action just prior in the list
if (username != "" && ActiveTest .Count > 0)
{
ActiveTest .RemoveAt (ActiveTest .Count - 1);
}
AddAction (nav );
}
public void AddAction (ActionBase action )
{
if (!Recording ) return ;
if (ShouldInsertActions )
{
InsertAction (InsertPosition , action );
InsertPosition ++;
return ;
}
ActiveTest .Add (action );
ActiveTest .UnsavedScript = true ;
action .ParentTest = ActiveTest ;
if (MainBrowser .OnGridAdd != null ) MainBrowser .OnGridAdd (action );
}
2 、 Search 接受的事件
search 接受键盘 keyup 事件,调用方法名 comboSearch_KeyUp( object sender , KeyEventArgs e) , 格式化字符串 str ,调用方法 NavToUrl( string str) ,后面的流程同 address 接受的事件
private void comboSearch_KeyUp (object sender , KeyEventArgs e )
{
if (e .KeyCode == Keys .Enter )
{
e .Handled = true ;
if (comboSearch .Text .Length == 0)
return ;
string str = comboSearch .Text .Replace (" " , "+" );
str = string .Format (Properties .Resources .SearchURL , str );
NavToUrl (str );
}
}
3 、 cEXWB 接受的事件
CommandStateChange 调用方法 cEXWB1_CommandStateChange
处理控件中的 CommandStateChange 事件
DocumentComplete 调用方法 cEXWB1_DocumentComplete
处理控件中的 DocumentComplete 事件
DownloadBegin 调用方法 cEXWB1_DownloadBegin
处理控件中的 DownloadBegin 事件
DownloadComplete 调用方法 cEXWB1_DownloadComplete
处理控件中的 DownloadComplete 事件
FileDownload 调用方法 cEXWB1_FileDownload
处理控件中的 FileDownload 事件
NewWindow2 调用方法 cEXWB1_NewWindow2
处理控件中的 NewWindow2 事件
NewWindow3 调用方法 cEXWB1_NewWindow3
处理控件中的 NewWindow3 事件
ProgressChange 调用方法 cEXWB1_ProgressChange
处理控件中的 ProgressChange 事件
RefreshBegin 调用方法 cEXWB1_RefreshBegin
处理控件中的 RefreshBegin 事件
RefreshEnd 调用方法 cEXWB1_RefreshEnd
处理控件中的 RefreshEnd 事件
ScriptError 调用方法 cEXWB1_ScriptError
处理控件中的 ScriptError 事件
SetSecureLockIcon 调用方法 cEXWB1_SetSecureLockIcon
处理控件中的 SetSecureLockIcon 事件
StatusTextChange 调用方法 cEXWB1_StatusTextChange
处理控件中的 StatusTextChange 事件
TitleChange 调用方法 cEXWB1_TitleChange
处理控件中的 TitleChange 事件
WBAuthenticate 调用方法 cEXWB1_WBAuthenticate
处理控件中的 WBAuthenticate 事件
WBDocHostShowUIShowMessage
调用方法 cEXWB1_WBDocHostShowUIShowMessage
处理控件中的 WBDocHostShowUIShowMessage 事件
WBDragDrop 调用方法 cEXWB1_WBDragDrop
处理控件中,拖动事件