JavaScript errors on some pages during recording or replaying

While recording or replaying with QuickTest Professional (QTP) or Sprinter, errors may occurs against web application, for example::

Error: Object doesn’t support this action

Some of the JavaScript related:

"…

elem.appendChild = function(child) { var res = __QTP__HOOK_NOTIFIER.AppendChild(elem, child); QTP_EPE_HOOK.NotifyAgentOnDOMChange(); return res; };

…"

Called by object: QTP_EPE_HOOK.elementHook(childs[i]);

This error is not encountered when viewing the site without QTP or Sprinter.

The JavaScript error whenever QuickTest Professional (QTP), which Sprinter Power Mode uses, hooks to Document Object Model (DOM) mutation methods causing a problem/conflict in a QTP engine feature (focused on improving recording experience under Web Extensibility) where it tries to hook on element type that does not have DOM mutation method.

To fix, First try the following steps , if and only if, issue happens during recording (But replay is ok):

Determining which particular event is encountering problems will provide inside either for a fix or reconfiguration of QTP to allow proceeding with automation.

To analyze which events are causing the problem:

Access the Web Event Recording Configuration dialog (go to “Tools” and select “Web Event Recording Configuration” option

Click on “Custom Settings…” button to show “Custom Web Event Recording Configuration” dialog. Note: On the left side, a tree view control shows different types of web test objects and on right side are shown all events being listened/recorded

Before moving forward, backup/export to a file the current settings, by going to “File” and selecting “Save Configuration As”. Note: exported file can be “imported” by going to “File” and selecting “Load Configuration”

Expand “Web Objects” (under “Any Web Object” item on left side) and find/highlight/select test object showing problematic behavior

Once selected a test object, delete all the events displayed on right side of dialog (select event on list, then go to “Event” menu and select “delete)

Click “Ok” on currently opened dialogs to confirm changes and go to back to main screen of QTP

Confirm undesirable functionality against problematic test object isn’t happening no more. Note: it is expected to not record (scripts getting generated or objects getting added to repository)

Now add back each deleted event (with same settings as before on “Listen” and “Record” columns, testing problem after adding each event back

Note: Once determined which particular event (or multiple events) is reproducing issue, try following options if applicable

The following are workarounds to deal with scenarios where situation presents:

If "onclick" event is causing problem, replace it for “onmousedown” plus “onmouseup” events:

Delete the "onclick" event from under both item called "Any Web Object" and from item related to problematic test object (for example "Link") on the Web Recording Configuration dialog

Add/Insert both the events "onmousedown" and "onmouseup" events under modified items of step #1 with settings for "Listen" and "Record" the values "Always" and "Enabled" respectively

Go to QTP Tools menu, select "Options" and access the "Advanced" section for "Web" tab/option

Enable "Record settings > Record MouseDown and MouseUp as Click" option

Click "Apply" then "Ok" to go back to main screen

Click "New" to create a new blank test (or go to File > New > Test) or load desired test script (if already opened, close and reopen so new settings get applied to test)

Test new settings

In case is not "onclick" event the one causing conflict:

Start recording against problematic scenario

Once problem happens, stop recording

Refresh page/screen and confirm problematic object is now working. Note: it may be necessary reload entire browser to get support be loaded appropriately if refreshing the page/screen isn’t possible or such presents problems/restrictions

(Optional) On QTP Script, click the location where new recorded script lines will be inserted/appended.

Start recording once object is working correctly

Note: Repeat steps against each time during recording an object "looses" its functionality

IMPORTANT: In case script’s replay is also affected by this situation, then after the SYNC method usage on Browser test object, include another line using the REFRESHWEBSUPPORT method. For example:

‘…

Browser("MyApplicationWithLotsOfJavaScript").Sync

Browser("MyApplicationWithLotsOfJavaScript").RefreshWebSupport

‘…

If the above doesn’t apply, then try disable Web Extensibility mechanism feature via registry:

1. Close QTP and any related web application

2. Open Windows Registry Editor (Go to the Start menu, select “Run”, type “regedit” and click “Ok”)

3. Navigate to below: Note: below entries are 32bits paths

QTP:

HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest\Packages\WebPackage\Settings

Sprinter:

HKEY_CURRENT_USER\SOFTWARE\Hewlett-Packard\Manual Runner\MicTest\Packages\WebPackage\Settings

4. Modify the value for the key “EnableDOMChangesNotifications” to value 0

5. Repeat also step 4 under below. Note: below entries are 32bits paths; for 64bits path, search under HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\…

QTP:

HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\MicTest\Packages\WebPackage\Settings

Sprinter:

HKEY_LOCAL_MACHINE\SOFTWARE\Hewlett-Packard\Manual Runner\MicTest\Packages\WebPackage\Settings

6. Try again.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s