7、删除 接受的事件
点击按钮,调用方法tsbDeleteAction_Click(),通过wscript.DeleteAction(),从列表删除选择行,同时删除grid中的行
private void tsbDeleteAction_Click(object sender, EventArgs e)
{
if (gridSource.Selection.ActivePosition.Row == -1) return;
wscript.DeleteAction(gridSource.Selection.ActivePosition.Row - 1);
}
public void DeleteAction(int index)
{
ActiveTest.RemoveAt(index);
MainBrowser.DeleteGridRow(index);
}
8、生成脚本 接受的事件
接受鼠标click事件,调用方法cToolStripMenuItem_Click;然后调用WatinScript.cs中的GetCode 函数,调用CodeGenerator.cs中封装产生命令的代码, GetCode()是生成脚本的接口函数, GetActionCode将ActiveTest中的具体动作转换成脚本语言
private void cToolStripMenuItem_Click(object sender, EventArgs e)
{
string code = wscript.ActiveTest.GetCode(new CSharpCodeFormatter { FileDestination = false }, GetBrowserTypeSelected());
Clipboard.SetText(code);
}
public string GetCode(ICodeFormatter formatter, BrowserTypes browserType)
{
var generator = new CodeGenerator
{
Formatter = formatter,
Browser = browserType,
Table = ReplacementTable,
ActionList = this
};
return generator.GetCode();
}
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Text.RegularExpressions;
using TestRecorder;
using TestRecorder.Core.Actions;
using TestRecorder.Core.Formatters;
namespace TestRecorder.Core
{