Test for SWT Accessibility Features

Best practices, code snippets for common functionality, examples, and guidelines.
unittheory
Posts: 1
Joined: Wed Dec 06, 2017 3:09 pm

Test for SWT Accessibility Features

Post by unittheory » Wed Dec 06, 2017 3:37 pm

I have a SWT application in which the SWT accessibility features are used. The accessibility attributes are correctly implemented as popular screen reader tools are able to read them. Now I would like to test these features with Ranorex, however I am not sure on how to do this since the Spy tool does not seem to pick up on these attributes.

This is how accessibility features are used in SWT:
Text text = new Text(parent, SWT.NONE);
text.getAccessible().addAccessibleListener(new AccessibleAdapter() {
    @Override
    public void getName(final AccessibleEvent event) {
        event.result = "Accessible Text";
    }
});
The Accessible Object is used and the listener is called whenever an assistance tool asks for a name or description. This works for popular screen readers.

It seems Ranorex even picks up this object (dynamically), however the "AccessibleName" and "AccessibleDescription" fields are empty as can be seen in attached screenshot of the Spy view for the Text control in the code snippet.

Does anyone know how to configure Ranorex to ask for the accessible name and description or how to build a workaround to at least test for them?
Attachments
SWT-Accessible.png
Ranorex Spy Screenshots for SWT Accessible
SWT-Accessible.png (22.98 KiB) Viewed 475 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3916
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Test for SWT Accessibility Features

Post by odklizec » Thu Dec 07, 2017 10:59 am

Hi,

Could you please post a Ranorex snapshot (not just screenshot) of the problematic element(s)? Ideally, if possible, post also a small sample app showing the problem. This would help Ranorex folks to find the problem (and eventually suggest a solution) much faster. Thanks.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

ValentijnWibaut
Posts: 2
Joined: Fri Jan 26, 2018 2:39 pm

Re: Test for SWT Accessibility Features

Post by ValentijnWibaut » Fri Jan 26, 2018 2:56 pm

I have the exact same problem described above.
This is what my dummy SWT GUI looks like:
import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.*;
import org.eclipse.swt.widgets.*;

public class Main {

	public static void main (String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	
	Button dummyButton = new Button(shell, SWT.NONE);
	dummyButton.setText("Hoi ik ben een knop");
	dummyButton.pack();
	
	Label dummyLabel = new Label(shell, SWT.BORDER);
	dummyLabel.setSize(300, 30);
	dummyLabel.setLocation(100, 50);
	dummyLabel.setText("Hoi ik ben een label");
	
	Accessible accessibleDummyLabel = dummyLabel.getAccessible();
	accessibleDummyLabel.addAccessibleListener(new AccessibleAdapter() {	
		@Override
		public void getName(final AccessibleEvent e) {
			e.result = "Een naam";
		}
		@Override 
		public void getDescription(final AccessibleEvent e) {
			e.result = "Een beschrijving";
		}
	});
	
	dummyLabel.pack();
	
	shell.pack();
	shell.open ();
	while (!shell.isDisposed ()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
	}
	
}
The Spy detects the AccessibleListener, but Ranorex does not seem to call the getName() and getDescription() functions, or in any case it does not detect AccessibleName and AccessibleDescription attributes on the dummy label.
SpyAccessibleListener.png
SpyPrtScr
SpyAccessibleListener.png (64.21 KiB) Viewed 396 times

ValentijnWibaut
Posts: 2
Joined: Fri Jan 26, 2018 2:39 pm

Re: Test for SWT Accessibility Features

Post by ValentijnWibaut » Mon Jan 29, 2018 12:25 pm

[UPDATE]

Spy > Settings > Plugins > Solution Settings > Java

Set "Show SWT Custom Data Properties" and "Use Java SWT Legacy Automation Mode" to true.

The spy now picks up AccessibleName and AccessibleDescription properties from the SWT components