Testing Rich internet applications developed in Flex / Adobe Flash using Quick Test pro – Advanced troubleshooting.
There are some common problems and resolutions when you use QTP to test your Flex applications.
You can solve some common problems by ensuring the following information about your environment and application:
■ ActiveX version of the debugger version of Flash Player 9 (version 296) is installed.
■ Flex/QTP plug-ins are installed.
■ The application was compiled using Flex 2.0 with the new frameworks.swc file that supports automated testing.
■ The application is running in Microsoft Internet Explorer.
■ The application is loaded through an HTML page, with an <object> tag that has an id attribute set. The id attribute contains no periods or hyphens.
■ The application is loaded either from a web server or locally from a trusted SWF file.
If QTP does not record interactions with your Flex application, you should try to determine if the plug-in is installed. The following problems are the most common:
■ Flash Player is not the right version.
■ Internet Explorer is not the right version.
■ Internet Explorer has plug-ins turned off.
■ Plug-in was not installed.
■ DLLs that the Flex plug-ins are dependent on do not exist in the system. These include MSVCR71.DLL and MSVCP71.DLL.
You can determine the problem in the following ways:
■ View a list of installed plug-ins.
■ View the log files.
To help determine the source of problems, you can view Flash Debug Player and QTP log files.
Logging with Flash Debug Player
Flash Debug Player writes plug-in and ActionScript errors to the flashlog.txt file. The default location of this file is C:\Documents and Settings\user_name. To enable logging, you must configure mm.cfg. For more information, see Configuring the debugger version of Flash Player in Building and Deploying Flex 2 Applications.
Logging with QTP
You can configure QTP logging to log QTP errors related to application testing. You then view the QTP log file for possible sources of problems.
To turn on logging of the QTP log file:
1. Open a command line dialog box.
2. Go to the QTP bin directory. The default location is C:\Program Files\Mercury
3. Run MicLogSetting.exe. The MicLogSetting dialog box appears:
4. From the Level drop-down list, select MicLogLevelDebug2 as the level.
5. In the Folder field, select a folder where the log file is saved.
6. From the Available Categories list, select LogCatPackTEA, and click the right arrow
button to move it to the Selected Categories list.
7. Click OK to save your changes to the QTP log levels.
8. Run QTP. Record interactions with your Flex application as usual.
9. Close QTP.
10. Examine the QTP log file for potential problems.
Resolving playback synchronization issues
In some cases, the playback of a test script is not synchronized with what appears on the screen. For example, QTP does not wait for effects to finish or for data results to be returned before testing an object. This can result in QTP recording errors such as the following:
■ Your scripts play back inconsistently.
■ You experience an Unspecified Error.
■ Your scripts are failing in a spot where they should not be.
There are several solutions to these timing issues, which are described in the following sections.
Adding waits to scripts
You can use the Wait statement to pause a scripts playback for any number of seconds. You pass Wait(num_seconds) as an argument to the operation you want to pause in the script.
The following example waits 10 seconds before clicking the Milk FlexCheckBox control:
For more information on using the Wait statements, see the QTP documentation.
Checking if objects exist
You can also check if the object exists before executing an operation on that control. To do this, you can use the Exist statement. The following example checks whether the Milk FlexCheckBox control exists before clicking on it:
If Browser("My Page").FlexApplication("MyApp").FlexCheckBox("Milk").Exist
You can also check for the value of the Exist common property on the control. For more information on using the Exist statement or the Exist common property, see the QTP documentation.
Slowing global playback times
You can configure QTP to play all events slower by setting a global execution delay. This should be considered a last resort. In very
large testing scripts, increasing the time it takes for each event to fire, even by a fraction of a second, can dramatically increase the total run time of the test. Therefore, you should try to find the lowest possible value that lets your scripts run correctly.
If you do choose to add a global delay, you should configure QTP to delay each step in your script by some small number of milliseconds, and then gradually increase this amount until you do not experience any errors.
To add a delay to each step in your test:
1. Select Tools > Options.
2. In the Options dialog box, select the Run tab.
3. Select the Normal option for the Run mode. This is the default option.
4. Increase the amount of the Delay Each Step Execution By option to some number of milliseconds. The default value is 0.
5. Click OK to save your changes.
6. Rerun your test. If you still experience problems, increase the amount of the delay and rerun the test.
Delaying startup test time
When you change an application, or recompile the application when QTP launches it in the
browser, you should consider delaying the time that the tests start after the browser launches.
If you immediately start a test but the application has not finished instantiating all of its
objects, QTP might record failures.
To delay the start of the test:
1. Select Tools > Options.
2. In the Options dialog box, select the Web tab:
3. Increase the amount of the Add n Seconds To Page Load Time option to a number large enough to ensure that your application compiles before QTP starts running the test.
Making a test fail but continue to the end
You may encounter situations where you cannot make the test fail or pass from a script and still continue to the end. Specifically, this has been reported for tests that change a formula within a Data Table.
To write a QTP method that causes a test to fail but continue to the end, you create a keyword, as the following example shows:
Public Function WidthGreaterThan(test_object, minWidth)
actual = test_object.GetROProperty("width")
a = CInt(actual)
b = CInt(minWidth)
If a > b Then
Msg = "WidthGreaterThan", "Width is greater than: " &minWidth
Reporter.ReportEvent micPass, Msg
Msg = "Width " & actual & " is not greater than " & minWidth
Reporter.ReportEvent micFail, "WidthGreaterThan", Msg
RegisterUserFunc "FlexButton", "WidthGreaterThan", "WidthGreaterThan"
FlexButton("Remove from cart_11").WidthGreaterThan 10
FlexButton("Remove from cart_11").WidthGreaterThan 1099
FlexButton("Remove from cart_11").WidthGreaterThan 100
Limitations of automated testing with
Flex The Flex integration with QTP includes the following limitations:
■ Flex test objects do not show up in the Object Identification (Tools > Object Identification) dialog box. Therefore, you generally do not configure the way QTP gets an object id or customize which properties QTP stores. You can configure the properties that Flex uses to identify an object in the TEAFlex.xml file.
■ Web settings (Tools > Web Event Recording Configuration) do not apply to Flex applications. This is where you can specify the sensitivity of mouse events (for example, instruct QTP to record a mouseDown and then a mouseUp operation, rather than a click operation).
■ Flex test objects are not in the QuickTest Object Model Reference (Help > QuickTest Professional Help > Contents tab > QuickTest Object Model Reference). This reference shows all the testable methods and properties, examples, and a list of identification properties. You can refer to the tea.html file that describes all the Flex test objects, their events, and event values.