Terminal Emulator code samples

Wait for text in the emulator screen

This example demonstrates how to use terminal emulator objects and their respective properties to wait for a text in the emulator screen.


[Test]public void TestWaitForText()
{
	// Following is the program flow: 
	// 1. Need to have a Terminal Emulator configured.
	// 2. Identify a TeScreen test object based on some descriptive properties.
	// 3. Select text from the emulator screen that you want to wait for. Example "Program/procedure". OR
	//    The user can insert text into a field and verify with WaitForText method if the text was inserted.
	// 4. Define an Area() object where the text is located and select the timeout in milliseconds.
	// 5. Call method WaitForText() with all above parameters and for the text string use regular expression to find it.
	// 6. The test has two cases: when the text exists on the screen and when not.
	// 7. Use the Assert statement to verify that "Program/procedure" exsits on the emulator screen.

	//Identify IWindow and IScreen based on descriptive properties.
	IScreen screen = Desktop.Describe<IWindow>(new WindowDescription
	{

		EmulatorStatus = HP.LFT.SDK.TE.EmulatorStatus.Ready,
		Protocol = HP.LFT.SDK.TE.Protocol.Pr5250

	}).Describe<IScreen>(new ScreenDescription
	{
		Label = @"screen10365"
	});

	//Identify IField based on descriptive properties.
	IField field = screen.Describe<IField>(new FieldDescription
	{
		AttachedText = @"User",
		IsProtected = false
	});

	//Insert dummy text to an unprotected field.
	field.SetText("Something");


	//Call WaitForText method with the inserted text to find it on the emulator screen.
	//The method will return a bool to indicate if the text was found or not. For this case, we should have true.
	//If we don't create an Area object, the method will search in whole screen.
	bool isText = screen.WaitForText(As.RegExp("Something"), 500);
	Assert.IsTrue(isText);

	//Call WaitForText method with below parameters to find the text on the emulator screen.
	//The method will return a bool to indicate if the text was found or not. For this case,  we should have true.


	bool onscreen = screen.WaitForText(As.RegExp("Program/procedure"), new Area(8, 17, 8, 33), 500);
	Assert.IsTrue(onscreen);

	//Call WaitForText method with below parameters to find the text on the emulator screen.
	//The method will return a bool to indicate if the text was found or not. For this case, we should have false.
	bool notonscreen = screen.WaitForText("12352", new Area(8, 17, 8, 33), 500);
	Assert.IsFalse(notonscreen);
}

Back to top

Send a TE Key on the screen

This example demonstrates how to use terminal emulator objects and their respective properties to send a TE Key on the screen

[Test]

public void TestSendTEKeys()
{
	// Following is the program flow: 
	// 1. Need to have a Terminal Emulator configured.
	// 2. Identify a TeScreen test object based on some descriptive properties.
	// 3. Call method SendKey() with a string as parameter example "Something" and a TE Key example Backspace.
	// 4. Call WaitForText() method to verify if the inserted text exists.
	//Identify IWindow and IScreen based on descriptive properties.
	IScreen screen = Desktop.Describe<IWindow>(new WindowDescription
	{

		EmulatorStatus = HP.LFT.SDK.TE.EmulatorStatus.Ready,
		Protocol = HP.LFT.SDK.TE.Protocol.Pr5250

	}).Describe<IScreen>(new ScreenDescription
	{
		Label = @"screen10365"
	});

	//Call SendTEKeys method with a string and a TE Key
	//The method will send to the emulator screen (at the cursor position) the string text + the TE Key.
	screen.SendTEKeys("Something" + LFT.SDK.TE.Keys.BACKSPACE);

	//Call WaitForText method with inserted text to find it on the emulator screen.
	//The method will return a bool to indicate if the text was found or not. For this case, we should have true.
	//If we don't create an Area object, the method will search in whole screen.
	bool isText = screen.WaitForText(As.RegExp("Somethin"), 500);
	Assert.IsTrue(isText);
}

Back to top