Test recorder的源码分析(3)

本文介绍了Test Recorder中删除事件的处理,包括在tsbDeleteAction_Click方法中调用wscript.DeleteAction进行删除,并在DeleteAction方法中更新主浏览器和ActiveTest。接着详细阐述了脚本生成的过程,通过cToolStripMenuItem_Click事件触发,调用GetCode方法,利用CodeGenerator生成具体的脚本代码。
摘要由CSDN通过智能技术生成

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()是生成脚本的接口函数, GetActionCodeActiveTest中的具体动作转换成脚本语言

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

{

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值