Mobile web scripts

Use the Recorder to create scripts to test both adaptive and responsive websites as they appear on mobile devices.

Adaptive websites are separate from an organization's main website. When a mobile device browser accesses an adaptive website, the browser is redirected to a mobile version of the website. Also, adaptive websites are configured for predefined screen sizes, so may not work well for each mobile device.

Responsive websites are more flexible than adaptive websites. Any desktop or mobile device browser can access a responsive website because the site automatically adjusts to the device that is connecting to it.

Overview of recording mobile web scripts

The high-level steps to record a mobile web page are:

  1. Open the Recorder.

  2. Click REC.

  3. Select Mobile Device.

  4. If a default device is not specified, select the mobile device to emulate.

  5. Type the URL of the website.

  6. On the website, perform the actions to include in the script.

  7. When you are finished, click STOP.

  8. Play back the script to make sure it runs successfully.

  9. If necessary, modify the script.

  10. Upload the script to the Dynatrace Portal and create a test to run the script on designated mobile nodes.

For a detailed procedure for recording scripts to test mobile websites, see Creating Mobile Device scripts.

For information on playing back mobile web scripts and viewing results, see Playing a script and its subtopics.

Mobile settings and defaults

If the changes you plant to make to the script settings apply to every mobile script, you can change the default settings before recording a script.

The following table lists the settings that can be changed for a mobile script, with their default values.The settings are described in more detail below.

Setting Default for Mobile Scripts Global Preference
Recording Profile Desktop Yes. Change on the Recording tab in the Global Preferences window.
Keystrokes/FormFill Keystrokes ON Yes. Change on the Recording tab.
HTTP Capture On/Off Off Yes. Change on the Recording tab.
Scroll Capture On/Off Off Yes. Change on the Recording tab.
Device None Yes. Change these settings by selecting Mobile Profile on the Recording tab. If you select a default mobile device in the Global Preferences, the Use Agent, Screen width, and Screen height defaults are also set.
User Agent Default Playback Agent - Mobile Yes. If a device is selected in Global Preferences, this field is automatically populated with the information related to the device.
Headers None None. See Headers, below
Screen width None Yes. These fields are blank unless a device is selected in Global Preferences.
Screen height None Yes. These fields are blank unless a device is selected in Global Preferences.
Device Pixel Ratio None Yes. These fields are blank unless a device is selected in Global Preferences.
Concurrent connections per host (max) 6 Yes. Any number from 1 through 6.
Simultaneous HTTP requests (max) 18 Yes. Any number from 1 through 18.

Recording settings

The following settings are available when you begin recording and select Mobile Device as the recording type:

  • Select device
  • Customize
  • Select Location
  • Keystrokes/FormFill
  • HTTP Catpure
  • Scroll Capture

Mobile recording settings

Playback settings

After you click Stop to finish recording the script, the Recorder displays the script settings tabs where you can review the settings and modify them if needed.

Profile

Mobile profile settings

Profile selection

By default, the device you selected before recording the script is listed as the Mobile Device.

Profile selection settings

Click Change device to open the Device Manager. Select the device name and click OK.

Device manager

Optionally, you can change the device headers, if necessary, by clicking Select Alternative Header Set in the Device Manager.

Concurrency limits

Mobile concurrency limits settings

  • Concurrent connections per host (max) – The maximum number of simultaneous HTTP connections allowed to connect to a single host. The default is 6.

  • Simultaneous HTTP requests (max) – The maximum number of total requests allowed to execute at the same time. The default is 18.

Customize profile

Customize profile settings - Mobile

Customize

Click Customize to open the Customize Profile window, where you can do one of the following:

  • Change these settings:

    • Device Name
    • User Agent
    • Screen width
    • Screen height
    • Concurrent connections per host
    • Simultaneous HTTP requests
  • Click Load to load an existing profile.

Customize profile window

Load

Click Load to load an existing profile (.gprof file).

Save

You can save these settings as a profile. Click Save, enter a file name, and click Save.

Mobile location

Mobile location settings

Specify a location to emulate a mobile device's ability to provide GPS information. Click Select Location to open the Mobile Location dialog box. This option is available only after you select Mobile Device.

Mobile location dialog box

Select from the list:

  • No Location – The default. The script will not use location information.

  • Custom Location – Enter latitude and longitude in the fields. For southern latitude and western longitude, use negative numbers.

  • Use the mobile node location – If this option is enabled, when the script is uploaded to the Dynatrace Portal and provisioned, it uses the location of the mobile node that runs the script.

    Because node coordinates are not available when you run the script locally, selecting this option displays fields for you to enter latitude and longitude GPS coordinates for local playback. If you leave these fields blank, the script uses the default location of Detroit, Michigan. When the script is uploaded to the Dynatrace Portal, the node location overrides these local playback coordinates.

Headers

Headers tab

User agent

The user agent is a header sent on each request that identifies the client browser. Changing this field does not change the browser that the script is played back in (that depends on the playback agent), but it does change what the server or web application sees as the client. By default, the playback agent uses its default setting. If you selected a mobile device, its user agent header is here. You can enter any string here. The Recorder provides default strings of some common browsers. Select Change To and select the browser to use. For Mobile Device scripts, make sure you select an appropriate browser for mobile websites.

Selecting User Agent for Mobile playback

Headers

If the selected mobile device sends headers with each request, they are listed here. You can edit them if necessary.

Parameters

Add parameters to the script after it has been recorded and plays back successfully. On this tab, you can define a parameter by entering a value you entered when the script was recorded and providing a descriptive name to identify the parameter within the Recorder and the Dynatrace Portal. The parameters are defined at the script level.

Parameters are stored in the script's JSON structure within an array named parameters. The JavaScript syntax for referencing a script parameter is:

parameters['paramName']

Parameters can be referenced from within a Custom action as well as used within a standard action using the backtick method.

The Apply Parameter button in the Type and FormFill action panes auto-generates a reference to the parameter chosen from the list and automatically wraps the statement in backticks in order for it to be evaluated.

For example, when you originally recorded the script, you may have used the account number 123456. After the recording is complete, you can specify a parameter with the value of 123456 and a descriptive name of Account Number.

Using the Account Number from the example described above, you can declare the following:

 document.forms['form1].elements["accountNum"] = parameters["Account Number"];

In addition, you can use parameters in any text field in any action in the script by using evaluation syntax. Evaluation syntax causes the text to be evaluated at runtime. To use evaluation syntax, surround any text with backticks ( ` ). You can enter any valid JavaScript between the backticks. This syntax is commonly used in FormFill actions, as they enable you to set the value of any form element on a page.

Some of the common uses of parameters are:

  • Dynamic dates
  • Transactions that require a unique ID, such as a Session ID, for each test run.
  • Scripts that require randomization, such as clicking a random search result.

To use a FormFill action with parameters, add the action to the script in an appropriate place and define the target window and locator. Use the following syntax to define the parameter in the Value field:

`parameters["ParameterName"]`

For example, using the Account Number, enter the following in the Value field:

`parameters["Account Number"]`

After you define a parameter, you can have either the Text (for Type actions) or Value (for FormFill actions) fields automatically populated with the appropriate syntax for using a parameter.

For more information, see Setting parameters.

Adding parameters

  1. In the script, select the Parameters tab to define script-level variables.
  2. On the right side of the tab, click the add button , then enter the name in the Name field and the default value in the Default Value field. Repeat this step to add more parameters.
    Adding parameters
    After you define the parameter, it can be used by defining a custom action in the script.

Specifying parameter syntax

  1. In the script, select the action and click Apply Parameter next to the Text field (for Type actions) or Value field (for FormFill actions). The possible parameters appear in a drop-down list.
    Selecting parameter

  2. Select the parameter to apply. The parameter syntax for the selected parameter appears in the field.
    Parameter syntax

Playback

These settings are available for mobile script playback:

  • Enable SPDY
  • Include client (non-network) time in results

Playback settings that do not apply to mobile device scripts are disabled when a mobile device is selected for playback.

Playback settings for Mobile scripts

Enable SPDY

This option does not apply to native application scripts.

Select this option to use the SPDY transfer protocol during script playback for mobile web scripts.

For example, you can create separate scripts that record the same actions with SPDY enabled and disabled, to compare performance in each situation.

When you play back the script with SPDY support enabled, the results views include SPDY data.

Include client (non-network) time in results

To view client (non-network) time, select here to include it in the results. If you select this option, then the waterfall chart displays this non-network time as gaps in the chart.

When you select this option and play the script using the Mobile agent, the waterfall chart displays W3C navigation time metrics.

Certificates

You can use client-side certificates while recording and playing back a script. The Recorder uses the industry standard PKCS12 certificates that have a .p12 file extension.

In some cases, one certificate is required while recording a script, but a different certificate is required when playing the script back.

Add certificates for recording through the File > Certificates command. These certificates are used by any script that requires them.

Use the Playback tab to add a certificate for playing back the current script:

  • The certificate must be a PKCS12 (.p12) file.
  • You can only add one certificate per script.
  • The certificate's password is displayed in the Playback tab of the script settings. It is not encrypted.
  • The Recorder does not validate the certificate or the certificate password.
  • The certificate is used only on playback.

Certificate tab

For information on adding certificates for recording and playback, see Using certificates.

Hosts

On this tab, map the domains that are used by the script by specifying destination IP addresses or hostnames.

Entering values here allows the test to ignore the system/Internet DNS servers. This may be useful when you are testing a network or a website that is not yet public.

Hosts tab

  1. On the Hosts tab, click the add button .
    A new set of definition fields is added to Host Mapping.

  2. In the Hostname field on the left, enter the hostname to map, for example, MyWebSite.com.

  3. From the Map To drop-down list, select whether to map to an IP Address or Hostname.

  4. In the Destination fields, enter a maximum of three IP addresses or hostnames.

  5. To map additional hostnames, click the add button on the far right, and repeat the preceding steps.