【问题标题】:How can I automate Delphi Firemonkey UI testing without access to source code?如何在不访问源代码的情况下自动化 Delphi Firemonkey UI 测试?
【发布时间】:2015-05-12 17:41:08
【问题描述】:

如何在不访问源代码的情况下自动化 Delphi Firemonkey UI 测试?

我目前在 DUnit 和 TestComplete 测试中针对我的应用程序运行了一套测试。我正在考虑将 UI 从基于 VCL 移动到基于 FireMonkey。我意识到我的测试需要重写,但是我注意到我们使用的 UI 测试软件无法“查看”应用程序并查看控件及其属性。所有工具都可以看到表单,而不是看到编辑框或标签。我相信这是因为 Firemonkey 用于渲染控件的轻微手。 UI 测试可以使用 DUnit 实现,但这需要我们的测试人员能够访问源代码,这在我工作的地方不受欢迎。有人知道解决方案吗?

谢谢。

【问题讨论】:

  • fmx 有一个插件,增加了 UI 自动化支持
  • 我猜大卫指的是这个:docwiki.embarcadero.com/RADStudio/XE8/en/…
  • @Stefan 是的,就是这样。我永远记不起它叫什么,完全没有 fmx 的经验。
  • 谢谢!这正是我所希望的。现在我只需要对其进行测试,看看它是否像宣传的那样工作。
  • 无法让它工作。该问题可能发生在测试软件方面。试图设计一种方法来测试问题出在哪一边。

标签: delphi firemonkey ui-testing


【解决方案1】:

Build a test harness.

function TForm1.FindControlAtPoint(aParent: TControl; aPos: TPointF): TControl;
var
  I: Integer;
  Control, ChildControl: TControl;
  S: String;
begin
  Result := nil;

  // Check all the child controls and find the one at the coordinates
  for I := aParent.Controls.Count – 1 downto 0 do
  begin
    Control := aParent.Controls[I];
    S := Control.ClassName;
    if Control.PointInObject(aPos.X, aPos.Y) then
    begin
      ChildControl := FindControlAtPoint(Control, aPos);
      if Assigned(ChildControl) and ChildControl.HitTest then
        Exit(ChildControl)
      else if Control.HitTest then
        Exit(Control);
    end;
  end;
end;

【讨论】:

  • 您建议如何在无法访问源代码的测试人员级别调用此测试工具?
  • 您创建了一个自动鼠标宏,您可以在其中记录鼠标移动和点击,然后回放它们。您可以在每次单击后保存图像以供将来参考(以验证应用程序在单击后处于您想要的阶段)。您还可以使用它来存储单击的按钮的名称,然后循环并稍后自动查找控件(以处理控件是否被移动而不是依赖鼠标宏)。
  • 它不适用于 TWebBrowser、TMapView 和可能的 TListView(自定义绘制)等原生控件。
猜你喜欢
  • 2020-09-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多