2

I'm currently adding the IAccessible-Interface to my derived VCL-Components to be able to implement automated UI-Testing for my application.

After implementing the interface i didnt see the name in the properties of my components read out via external tools, though i saw while debugging it was set. After "some" (or more likely very much) testing around i found out, that the return value of Get_accState seems to be influencing the name:

When I return S_OK in this function (independet from the State i set), my Control name is empty, else it's the value set in Get_accName.

Am I doing something wrong? Why does this happen? To me it seems like a bug of MSAA, though this is unlikely...


This is the function setting the name:

function TXControlEigenschaften.Get_accName(varChild: OleVariant; out pszName: WideString): HResult;
begin
  pszName := '';
  Result := ValidateChildId(varChild);
  if Result = S_OK then
  begin
    if AccessibleName <> '' then
      pszName := AccessibleName
    else
      pszName := FControl.Name;
  end;
end;

When I do it like this, the name is there:

function TXControlEigenschaften.Get_accState(varChild: OleVariant;
  out pvarState: OleVariant): HResult;
begin
  Result := DISP_E_MEMBERNOTFOUND;
end;

But when it's like this, how I want it to be, the name is empty:

function TXControlEigenschaften.Get_accState(varChild: OleVariant;
  out pvarState: OleVariant): HResult;
begin
  Result := ValidateChildId(varChild);
    if Result = S_OK then
      pvarState := STATE_SYSTEM_FOCUSED;
end;

I'd even leave it like this, if there wouldn't be a problem with selecting the components via UI-Test Recorders when the state isn't set properly.

Florian Koch
  • 1,372
  • 1
  • 30
  • 49
  • I am going to implement this interface as well. Did you ever get any further? – Jeroen Wiert Pluimers Dec 07 '18 at 18:10
  • 1
    @JeroenWiertPluimers sorry, I didn't further pursue this, so there isn't any more information I could give you. I don't even know if this still behaves the same with newer Delphi Versions – Florian Koch Dec 09 '18 at 16:53
  • No problem. In the mean time I have found https://stackoverflow.com/questions/16320914/creating-accessible-ui-components-in-delphi/16322828#16322828 so I am going to give that a try. – Jeroen Wiert Pluimers Dec 09 '18 at 16:59

0 Answers0