User Lib question

Wednesday, November 7, 2018
Avatar

I have created a user library where I added the StartDynamics() function:

/** Base Functions **/
function StartDynamics() {
	var dynamicsPath = "C:\\Program Files (x86)\\Microsoft Dynamics AX\\60\\Client\\Bin\\";
	var dynamicsFullPath = dynamicsPath + "Ax32.exe";
	var dynamicsQA = " \\\\DAX-RDS-101-WD\\AX_config\\QA_CUS.axc";
	var windows = g_util.FindWindows("regex:.Microsoft Dynamics AX.*", "AxMainFrame");
	if (!File.Exists(dynamicsFullPath)) {
		Tester.FailTest("Dynamics AX Client is not installed on this computer");
		return;
	}
	if (windows.length == 0) {
		Global.DoLaunch(dynamicsFullPath, dynamicsPath, false);
		Global.DoSleep(10000);
		if (SeSFindObj('QA')) {
			SeS('OK1').DoClick();
			Tester.Message('QA');
		}
		if (SeSFindObj('Communication_error')) {
			SeS('OK2').DoClick();
			Tester.Message('Communication error');
			Global.DoLaunch(dynamicsFullPath + dynamicsQA);
			Global.DoSleep(15000);
			if (SeSFindObj('Communication_error')) {
				SeS('OK2').DoClick();
				Tester.FailTest('Communication error');
			}
		}
		Global.DoWaitFor('Home', 60000, 5000);
	}
	maximize('UIAutomation');
	SeS('TabControl').DoSelectTab("Home");
}

I call the function in the TestInit() function in all the tests:

function TestInit()
{
	StartDynamics();
}

LibBase.jslib file:

SeSRegisterLibrary(
	{
		name: 'Base',
		description: 'Base - Default user-defined library',
		include: 'Lib/LibBase/LibBase.js',
		info: null,
		load_order: 1000,
		recording: false, // Only use in playback. If it has recording rules then set it to 'true'
		autoload: true // Always load this library for this test and each subtest
	}
);

 

The problem is that the tests occasionally fail on the line in TestInit() where I call the StartDynamics() function from the LibBase.js library with: "TypeError(-2146823281): 'Handle' is null or not an object' and only if the Dynamics is not started.

Now, my questions are:

1. Is TestInit() or TestPrepare() better for this kind of function?

2. Should I edit some parameters in the LibBase.jslib file so it reads the LibBase.js immediately on running (if that is the problem here)

4 Replies
Friday, November 9, 2018
Avatar
re: Hristovski Wednesday, November 7, 2018

Hi Dimitar,

I think that 'TestInit' is a good place to call 'StartDynamics'. I suggest to run the test with Internal Debugger and step into 'StartDynamics' function to find out where it fails (I believe it is successfully executed from 'TestInit').

I also suspect that the failure is in 'maximize' function you call in the end of 'StartDynamics'.

Regards,

Denis

Friday, November 9, 2018
Avatar
re: inflectra.max Friday, November 9, 2018

maximize is a very simple function.

function maximize(window) {
    SeS(window).getDesktopWindow().Maximized = true;
}

I'll try it with Internal Debugger and post the results

Friday, November 9, 2018
Avatar
re: Hristovski Friday, November 9, 2018

I would recommend logging as a help desk ticket if you need more help as we don't check the forum posts as frequently.

Friday, November 9, 2018
Avatar
re: inflectra.david Friday, November 9, 2018

Hi,

This happens rarely, but if this keeps on repeating and we don't find what causes it, I will raise a ticket.

Spira Helps You Deliver Quality Software, Faster and With Lower Risk

And if you have any questions, please email or call us at +1 (202) 558-6885

 

Statistics
  • Started: Wednesday, November 7, 2018
  • Last Reply: Friday, November 9, 2018
  • Replies: 4
  • Views: 5317