1

我想为我的 wpf 应用程序创建一个“模糊测试”,它可以处理随机用户事件的冲击。

关于如何做到这一点的任何想法。我看到了像 Ranorex 这样的工具,我可以在其中自动化 Ui 事件以进行测试自动化,但我真的想随机而不是有序地进行。

谢谢!

4

1 回答 1

2

您可以编写自己的单独“猴子测试”工具来进行随机点击。

为此,请获取窗口的边界,然后单击该矩形内的随机坐标。

代码看起来像:

// 1) Find the process
var processes = Process.GetProcessByName("MyWPFApp");

// 2) Get handle to its window, find its bounds/rectangle
IntPtr handle = processes[0].MainWindowHandle;

RECT rect;
GetWindowRect(handle, out rect));

// 3) Send clicks to the window
SendClicksToRect(rect); //you will need to implement this method, 
// it will use mouse_event() as mentioned here: https://stackoverflow.com/questions/2416748/how-to-simulate-mouse-click-in-c

请注意,您将要添加错误检查,上面的代码不会这样做

使用方法:

编写自己的代码的好处是您可以自定义它以遵循用户的场景[*],从而比随机点击更多的代码。

[*] 就像在执行一个场景,然后做一些随机点击

于 2013-05-01T23:03:36.737 回答