How can I automate Delphi Firemonkey UI testing without access to source code?
如何在不访问源代码的情况下自动执行Delphi Firemonkey UI测试?
I currently have a suite of tests running against my application in both DUnit and TestComplete tests. I am looking at moving the UI from VCL based to FireMonkey based. I realize my tests will need to be rewritten, however I noticed that the UI testing software we use cannot "look-into" the application and see the controls and their properties. Instead of seeing an editbox or a label, all the tools can see is the form. I believe this is the case because of the slight of hand that Firemonkey uses to render the controls. The UI tests can be implemented using DUnit, but this requires our testers to have access to the source code, which is frowned upon where I work. Is anyone aware of a solution?
我目前在DUnit和TestComplete测试中都有一套针对我的应用程序运行的测试。我正在考虑将UI从基于VCL的移动到基于FireMonkey。我意识到我的测试需要重写,但是我注意到我们使用的UI测试软件无法“查看”应用程序并查看控件及其属性。所有工具都可以看到,而不是看到编辑框或标签。我相信这是因为Firemonkey用于渲染控件的轻微手牌。 UI测试可以使用DUnit实现,但这需要我们的测试人员访问源代码,这对我工作的地方不满意。有人知道解决方案吗?
Thanks.
1 个解决方案
#1
构建测试工具。
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;
#1
构建测试工具。
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;