• 大小: 37KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-03
  • 语言: 其他
  • 标签: TestMonkey  

资源简介

C# 笨猴子测试工具 源码来源Sybex.Effective.GUI.Test.Automation.Developing.an.Automated.GUI.Testing.Tool.pdf

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace TestMonkey
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private StringBuilder smtInfo;
        private bool IsHearder=false ;

        private void SaveSmartMonkeyKnowledge(string textToSave)
        {
            string fileToSave = @“C:\smartMonkeyInfo.csv“;
            FileInfo fi = new FileInfo(fileToSave);
            StreamWriter sw = fi.CreateText();
            if (!IsHearder)
            {
                sw.Write(“CursorXCursorYHWndClassNameCaptionText\n“);
                IsHearder = true;
            }
            
            sw.Write(textToSave);
            sw.Close();

            
        }

        private void btnStart_Click(object sender EventArgs e)
        {
            if (tmrMonkey.Enabled)
            {
                tmrMonkey.Enabled = false;
                btnStart.Text = “Start“;
                SaveSmartMonkeyKnowledge(smtInfo.ToString());
            }
            else
            {
                tmrMonkey.Enabled = true;
                btnStart.Text = “Stop“;
                smtInfo = new StringBuilder();
            }
 
        }

        private void tmrMonkey_Tick(object sender EventArgs e)
        {
            tmrMonkey.Interval = (int)numInterval.Value * 1000;

            Random rnd = new Random();
            int x = rnd.Next();
            int y = rnd.Next();

            smtInfo.Append(x + “ “ + y + “ “);


            MouseAPI.MoveMouse(this.Handle.ToInt32() x y);
            MouseAPI.ClickMouse(MonkeyButtons.btcRight 0 0 0 0);
            MouseAPI.ClickMouse(MonkeyButtons.btcLeft 0 0 0 0);
            MouseAPI.ClickMouse(MonkeyButtons.btcWheel 0 0 x % 2000 0);

            int wHdl = 0;
            StringBuilder clsName = new StringBuilder(128);
            StringBuilder wndText = new StringBuilder(128);
            MouseAPI.GetSmartInfo(ref wHdl ref clsName ref wndText);
            smtInfo.Append(wHdl + “ “ + clsName.ToString() + “ “ + wndText.ToString() + “\n“);
        }

        private void Form1_Load(object sender EventArgs e)
        {
            //SaveSmartMonkeyKnowledge(“CursorXCursorYHWndClassNameCaptionText“);
        }

    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        766  2002-01-21 14:44  TestMonkey\Monkey.ico

     文件      24576  2008-06-08 08:11  TestMonkey\TestMonkey\bin\Debug\TestMonkey.exe

     文件      26112  2008-06-08 08:11  TestMonkey\TestMonkey\bin\Debug\TestMonkey.pdb

     文件       5632  2005-09-23 06:56  TestMonkey\TestMonkey\bin\Debug\TestMonkey.vshost.exe

     文件       2523  2008-06-08 08:11  TestMonkey\TestMonkey\Form1.cs

     文件       3984  2008-06-07 09:30  TestMonkey\TestMonkey\Form1.Designer.cs

     文件       6011  2008-06-07 09:30  TestMonkey\TestMonkey\Form1.resx

     文件       3886  2008-06-07 08:48  TestMonkey\TestMonkey\MouseAPI.cs

     文件        842  2008-06-07 09:31  TestMonkey\TestMonkey\obj\Debug\TestMonkey.csproj.GenerateResource.Cache

     文件      24576  2008-06-08 08:11  TestMonkey\TestMonkey\obj\Debug\TestMonkey.exe

     文件        180  2008-06-07 09:31  TestMonkey\TestMonkey\obj\Debug\TestMonkey.Form1.resources

     文件      26112  2008-06-08 08:11  TestMonkey\TestMonkey\obj\Debug\TestMonkey.pdb

     文件        180  2008-06-06 16:14  TestMonkey\TestMonkey\obj\Debug\TestMonkey.Properties.Resources.resources

     文件        289  2008-06-10 16:07  TestMonkey\TestMonkey\obj\TestMonkey.csproj.FileList.txt

     文件        477  2008-06-04 15:01  TestMonkey\TestMonkey\Program.cs

     文件       1310  2008-06-04 15:01  TestMonkey\TestMonkey\Properties\AssemblyInfo.cs

     文件       2847  2008-06-04 15:01  TestMonkey\TestMonkey\Properties\Resources.Designer.cs

     文件       5612  2008-06-04 15:01  TestMonkey\TestMonkey\Properties\Resources.resx

     文件       1093  2008-06-04 15:01  TestMonkey\TestMonkey\Properties\Settings.Designer.cs

     文件        249  2008-06-04 15:01  TestMonkey\TestMonkey\Properties\Settings.settings

     文件       3266  2008-06-06 16:14  TestMonkey\TestMonkey\TestMonkey.csproj

     文件        919  2008-06-04 15:01  TestMonkey\TestMonkey.sln

    ..A..H.     26112  2008-06-10 16:10  TestMonkey\TestMonkey.suo

     目录          0  2009-03-20 21:06  TestMonkey\TestMonkey\obj\Debug\TempPE

     目录          0  2009-03-20 21:06  TestMonkey\TestMonkey\bin\Debug

     目录          0  2009-03-20 21:06  TestMonkey\TestMonkey\obj\Debug

     目录          0  2009-03-20 21:06  TestMonkey\TestMonkey\bin

     目录          0  2009-03-20 21:06  TestMonkey\TestMonkey\obj

     目录          0  2009-03-20 21:06  TestMonkey\TestMonkey\Properties

     目录          0  2009-03-20 21:06  TestMonkey\TestMonkey

............此处省略4个文件信息

评论

共有 条评论

相关资源