Rational Test

 View Only

Tips & Tricks - RFT: Text Entry and Button Clicks in Transition from Internet Explorer to Edge

By Jerry Shengulette posted Thu December 01, 2022 05:24 PM

  

Transition: Internet Explorer to Microsoft Edge
Text Entry & Button Clicks

Your new browser is not the same as your old browser. This is especially true for modal alert dialog boxes.

Within the IBM Rational Functional Tester (RFT) community, we see a fair number of testers struggling as they attempt to migrate their automated test frameworks from Internet Explorer to one of the chromium-based browsers, Google Chrome or MS Edge. The user expectation is that this transition will be seamless. That is almost never the case, for reasons that have little to do with RFT itself.

Internet Explorer is very different from other browsers. It uses the deprecated ActiveX framework. It works with Java applets. This isn’t intended as a comprehensive list but as examples of things that have changed.

Let us look at another practical change, the handling of modal pop-ups. More specifically, we’ll be discussing text entry and button clicks on modal dialogs. The examples are a crude representation developed in-house just to illustrate the concepts.

Please note that this discussion relates specifically to RFT 10.5. It does not work with earlier version. These steps may be worth trying with later versions of the product, but later versions may offer different solutions. Certainly, the matter is getting priority attention from the development team.

Internet Explorer

Sample popup application renderd in Internet Explorer browser


If you click on the “Pop it up” button, a familiar modal dialog box appears.

Sample of modal dialog with text, a text box and two buttons rendered with Internet Explorer.


The “Explorer User Prompt” is an HTML construct accessible to RFT.  You can record and playback:

  • Data verification points for text on the dialog, for example the “Please enter your product name” text.
  • Text entry in the text entry box.
  • Button clicks on OK or Cancel.
Microsoft Edge
Sample popup application renderd in Microsoft Edge browser

When the button is clicked, we’d like to think the same dialog appears, but there is a subtle visual difference in the MS Edge version of the dialog.

Sample of modal dialog with text, a text box and two buttons rendered with Microsoft Edge.


Note that It is not quite the same dialog.  One of the characteristics of an HTML dialog box is that it can be moved around the entire window. This representation of a dialog box is not movable. What it is, in fact, is a browser construct intended to mimic an HTML dialog box. What we discover is that we CANNOT operate on these in the same manner as with Internet Explorer.  Text entry and button clicks on the dialog no longer work. We must take a different approach.

Recorded Code for IE

public class PopupIE extends PopupIEHelper
{
	public void testMain(Object[] args) 
	{
		startApp("PopUpIE");
		sleep(15);
		// Click the popup on the main page
		button_popItUpsubmit().click();
// Create a data verification point
label_htmlDialogStaticPleaseEn().performTest(	HtmlDialogStaticPleaseEnterYou_textVP());
		// Click on the text box on the popup
		text_htmlDialogEdit().click();
		// Enter text into box
		html_htmlDialog().inputChars("foobar");
		// Ciick the Cancel button
		button_htmlDialogButtonCancel().click();
	}
}

This code is typical of what you would see recording a simple test with Internet Explorer dialog boxes. It clicks a button on the main page which opens the popup, takes a data Verification Point from the popup, enters some text on the popup and clicks a button on the popup.

You’ll find none of that works if you replace Internet Explorer with MS Edge, and it’s all because MS Edge handles the modal dialog box differently. Text entry and button clicks on modal alert dialogs cannot be recorded.

The Workaround

The workaround requires 2 preference settings and then revolves around knowing how to navigate your alert box with keystroke actions and adding Java code to your scripts to accomplish that navigation.

Preference

  1. Open RFT.
  2. Navigate to Window > Preferences > Functional Test > Playback.
  3. Make sure the checkboxes for “Play back with Web UI Extension” and “Play back with Web UI Action” are checked.
    Highlighting boxes to check to have RFT functional test playback with Web UI playback engine.
  4. Click the Apply and Close button.

New Code for Edge

For the code, let us look at the example again.

Displaying sample popup application rendered in Microsoft Edge.


As the popup is rendered, the cursor is set in the text entry box. A single tab will move the focus to the OK button. A second tab will move the focus to the Cancel button.

The recorded testMain() method for the example looks like this:

	public void testMain(Object[] args) 
	{
		startApp("PopUpEdge");
		sleep(15);
		
		// HTML Browser
		// Document: file:///D:/tmp/PopUpWindo.html
		button_popItUpsubmit().click();
	}

This opens the application (from the local drive) and clicks the Pop it up button. Once the alert box is up, nothing else can be recorded.

	public void testMain(Object[] args) 
	{
		startApp("PopUpEdge");
		sleep(15);
		
		// HTML Browser
		// Document: file:///D:/tmp/PopUpWindo.html
		button_popItUpsubmit().click();

		IScreen screen = getScreen();
		screen.inputKeys("Rational Functional Tester");
		sleep(10); // delay to visually confirm text entry
		screen.inputKeys("{TAB}{ENTER}");
	}

The getScreen() method focuses the RFT playback engine on the top-level of the visible screen, presumably the alert box. As mentioned, the cursor is in the text box by default; thus the first call to the inputKeys() method fills in the text field. The second call to the inputKeys() method clicks the tab key (to move focus to the OK button) and then clicks the enter key, essentially clicking the OK button.

Implementing a variation of this code in your RFT 10.5 script should allow you to play back through modal alert boxes. It is not a 100% solution. There are some combinations of keys that are not supported. For example, combinations using keys like Cntrl/Shift/Alt do not work in this scenario.






















Permalink