Accessibility BUG?

Class library usage, coding and language questions.
martinbilski
Posts: 3
Joined: Fri Sep 21, 2007 10:53 am

Accessibility BUG?

Post by martinbilski » Fri Sep 21, 2007 11:26 am

Hi,

I'm evaluating RanorexCore to automate acceptance tests for our application but I'm having problems with accessibility features.

What I have problem with is accessing toolbar buttons. The application uses CodeJock (http://www.codejock.com) toolbar and apparently it doesn't work with your API. The reason I'm contacting you instead of CodeJock is that I believe there may be a bug in your API because Microsoft's AccExplorer displays and handles all toolbar elements correctly.

This is the element I'm trying to access. I tried the following:

Case 1. RxElementFindChild(&mainWindow, 0, "Send/Receive", NULL, &button)

Case 2. Iterating recursively over the elements to find one whose name matches "Send/Receive". When I do the latter, the following happens for the inner "xtpBarTop" element (you can see there are two nested elements with that name) -> RxElementGetChildCount returns the right number of elements (2) but the elements have empty names:

Code: Select all

...
[Parent = xtpBarTop]
	Child = 
	Child = 
...
while, according to AccExplorer, it should look like this:

Code: Select all

...
[Parent = xtpBarTop]
	Child = Standard
	Child = Menu Bar
...
Then trying to iterate over the first element (called "Standard" in the last listing) results in RxElementGetChildCount returning 7 but then RxElementGetChild for the third child element *fails*.

Could you please see what is causing this discrepancy between Microsoft's AccExplorer and your API? Thank you.

Below the code that will reproduce the bug (both cases described above). I removed all error checking code and replaced it with ASSERTs to make it more legible.

Note: You may need to change the path to the executable.

Case 1:

Code: Select all

		RxApplicationStart ("C:/Program Files/FollowUpXpert/FollowUpXpert.exe");
		HWND hwnd = RxFormFindClassName ("Xtreeme.FollowUpXpert.3.MainWndClassName");

		ASSERT (NULL != hwnd);

		ElementStruct mainWindow;
		ASSERT (RxControlGetElement (hwnd, &mainWindow));

		ElementStruct child;
		ASSERT (FALSE == RxElementFindChild (&mainWindow, 0, "Send/Receive", NULL, &child));
Case 2:

Code: Select all

		RxApplicationStart ("C:/Program Files/FollowUpXpert/FollowUpXpert.exe");
		HWND hwnd = RxFormFindClassName ("Xtreeme.FollowUpXpert.3.MainWndClassName");

		ASSERT (NULL != hwnd);

		ElementStruct mainWindow;
		ASSERT (RxControlGetElement (hwnd, &mainWindow));

		ElementStruct outerBarTop, innerBarTop;
		ASSERT (RxElementFindChild (&mainWindow, 0, "xtpBarTop", NULL, &outerBarTop));
		ASSERT (RxElementFindChild (&outerBarTop, 0, "xtpBarTop", NULL, &innerBarTop));
		ASSERT (2 == RxElementGetChildCount (&innerBarTop));

		ElementStruct standard;
		ASSERT (RxElementGetChild (&innerBarTop, 0, &standard));
		ASSERT (0 != strcmp (standard.Name, "Standard"));	// BUG: The name should be "Standard".

		ASSERT (7 == RxElementGetChildCount (&standard));

		ElementStruct child;
		ASSERT (RxElementGetChild (&standard, 0, &child));
		ASSERT (RxElementGetChild (&standard, 1, &child));
		ASSERT (FALSE == RxElementGetChild (&standard, 2, &child)); // BUG: There are 7 elements!
I'm testing using Windows XP Pro.

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Fri Sep 21, 2007 12:54 pm

Please try the following code:
(Thank you for the application and for the good description)

Code: Select all

// Finding form by titel
HWND form = RxFormFindTitle("FollowUpXpert - DEMO VERSION");	
if ( form == 0 )
{
	printf(" ERROR: Application not found\n");
	exit(1);
}

// Find the T O O L B A R
printf("Toolbar\n");
HWND hToolbar = ::RxFormFindChildClassName(form, "XTPToolBar"); 
if ( hToolbar == 0 )
{
	printf("    ERROR: Toolbar not found\n");
	exit(1);
}

// Get the Element of the Toolbar
ElementStruct element;
if ( RxControlGetElement(hToolbar, &element) == FALSE)
{
	printf("    ERROR: Toolbar GetElement\n");
	exit(1);
}

// Find and click the Send/Receive button
ElementStruct sendReceiveButton;
BOOL bRet = RxElementFindChild(&element, ROLE_SYSTEM_PUSHBUTTON, "Send/Receive", NULL, &sendReceiveButton);
if (bRet==TRUE)
{
	printf("    SendReceive button found\n");
	::RxMouseClickElement(&sendReceiveButton);
}
Jenö
Ranorex Team

martinbilski
Posts: 3
Joined: Fri Sep 21, 2007 10:53 am

Post by martinbilski » Fri Sep 21, 2007 2:28 pm

Nope, the code you sent doesn't work on my machine. Does it work on yours?

Details: It finds the toolbar all right, but not the button.

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Fri Sep 21, 2007 2:54 pm

Does it work on yours?
Yes, I tried also the Start and Stop buttons, they all work in my machine.
I use your demo version and have an english Windows XP.

Code: Select all

// Find and click the Start button
ElementStruct startButton;
bRet = RxElementFindChild(&element, ROLE_SYSTEM_PUSHBUTTON, "Start", NULL, &startButton);
if (bRet==TRUE)
{
	printf("    Start button found\n");
	//RxElementSelect(&listItem, SELFLAG_TAKEFOCUS | SELFLAG_TAKESELECTION);
	::RxMouseClickElement(&startButton);
}

// Find and click the Stop button
ElementStruct stopButton;
bRet = RxElementFindChild(&element, ROLE_SYSTEM_PUSHBUTTON, "Stop", NULL, &stopButton);
if (bRet==TRUE)
{
	printf("    Stop button found\n");
	//RxElementSelect(&listItem, SELFLAG_TAKEFOCUS | SELFLAG_TAKESELECTION);
	::RxMouseClickElement(&stopButton);
}
Jenö
Ranorex Team

martinbilski
Posts: 3
Joined: Fri Sep 21, 2007 10:53 am

Post by martinbilski » Fri Sep 21, 2007 3:06 pm

Could you send the project you used? Also, are you using v1.2? Thanks!

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Fri Sep 21, 2007 3:15 pm

Here my sourcecode, a command line application:

Code: Select all

#include "stdafx.h"
#include "RanorexCore.h" 

int _tmain(int argc, _TCHAR* argv[])
{
	RxSetSleepTime(150);
	RxMouseSetMoveTime(500);

	// Finding form by titel
	HWND form = RxFormFindTitle("FollowUpXpert - DEMO VERSION");	
	if ( form == 0 )
	{
		printf(" ERROR: Application not found\n");
		exit(1);
	}

	// Find the T O O L B A R
	HWND hToolbar = ::RxFormFindChildClassName(form, "XTPToolBar"); 
	if ( hToolbar == 0 )
	{
		printf("    ERROR: Toolbar not found\n");
		exit(1);
	}

	// Get the Element of the Toolbar
	ElementStruct element;
	if ( RxControlGetElement(hToolbar, &element) == FALSE)
	{
		printf("    ERROR: Toolbar GetElement\n");
		exit(1);
	}

	// Find and click the Send/Receive button
	ElementStruct sendReceiveButton;
	BOOL bRet = RxElementFindChild(&element, ROLE_SYSTEM_PUSHBUTTON, "Send/Receive", NULL, &sendReceiveButton);
	if (bRet==TRUE)
	{
		printf("SendReceive button found\n");
		::RxMouseClickElement(&sendReceiveButton);
	}

	// Find and click the Start button
	ElementStruct startButton;
	bRet = RxElementFindChild(&element, ROLE_SYSTEM_PUSHBUTTON, "Start", NULL, &startButton);
	if (bRet==TRUE)
	{
		printf("Start button found\n");
		::RxMouseClickElement(&startButton);
	}

	// Find and click the Stop button
	ElementStruct stopButton;
	bRet = RxElementFindChild(&element, ROLE_SYSTEM_PUSHBUTTON, "Stop", NULL, &stopButton);
	if (bRet==TRUE)
	{
		printf("Stop button found\n");
		::RxMouseClickElement(&stopButton);
	}

	RxSleep(3000);
	 
	exit(0);
}
are you using v1.2?
Yes

Jenö
Ranorex Team