Browser test tasks simulate user access to a target URL from different regions and network environments, monitoring the stability and performance of the target. By default, a new browser test task is in the running state and runs automatically at the configured frequency. This example shows how a Taobao developer uses script recording to assert website loading integrity in Google Chrome.
Prerequisites
-
You must have activated Network Analysis and Monitoring. For more information, see Activate Network Analysis and Monitoring.
For more information about the billing for browser tests, see browser tests.
-
You have created an alert contact or alert contact group. Create an alert contact or an alert contact group.
-
To use the alert callback feature, you need a public callback URL and must add the following IP addresses to your firewall's allowlist: 106.11.225.0/24, 106.11.226.0/24, 106.11.227.0/24, 106.11.242.0/24, 106.11.167.0/24, 106.11.245.0/24, 59.82.0.0/16, 59.82.84.0/24, 203.119.128.0/17, 203.119.156.0/24, and 121.41.9.246.
Limitations
Script recording is supported only on PC browsers.
Procedure
-
Create a browser test task.
-
Log on to the Cloud Monitor console.
-
In the left-side navigation pane, choose .
-
On the Monitoring Tasks tab, click Create Task.
-
On the Create Task page, configure the browser test task.
-
Basic information
Enter a DtsJobName. For Monitored Address, enter https://www.taobao.com/. For Browser and Device, select Chrome on PC. Use the default values for other parameters.
Parameter
Description
DtsJobName
The name of the browser test task.
The name must be 4 to 100 characters long and can contain letters, digits, underscores (_), and Chinese characters.
Monitored address
The URL of the target to test.
You can enter multiple URLs. Separate them with line breaks. Example:
https://www.taobao.com/.NoteIf you enter multiple URLs, a separate browser test task is created for each URL, consuming your task quota accordingly.
Monitoring frequency
The interval at which the browser test runs.
Valid values: 5 minutes, 15 minutes, 30 minutes, and 60 minutes. For example, if you select a 5-minute frequency, the agents in each region monitor the target URL every 5 minutes.
Browser and device
The browser (Chrome, Edge, Firefox, or Safari) and device (PC, tablet, or mobile phone) used to test the target URL.
Strict mode
When strict mode is enabled, the test task fails if any resource fails to load.
Certificate error
When enabled, certificate errors such as expired or mismatched certificates are ignored during the test.
Additional wait time
If your webpage redirects after it loads, set an additional wait time to ensure accurate data collection.
Customizations
Custom headers (including keys and values) and hosts (domain names and IP addresses).
NoteClick Advanced Settings to configure this parameter.
DNS server
The type of DNS server. Valid values:
-
System default DNS
-
The ISP DNS corresponding to the agent
-
Custom DNS
NoteClick Advanced Settings to configure this parameter.
DNS hijacking check
Configure an allowlist for ISP DNS hijacking.
NoteClick Advanced Settings to configure this parameter.
Traffic hijacking check
The items to check for traffic hijacking. Valid values:
-
Resource count threshold: Traffic hijacking is flagged when the number of loaded resources after a redirect exceeds this threshold.
-
resource blocklist: The resources that you expect not to appear on the page during loading.
-
resource allowlist: The only resources that you expect to appear on the page during loading.
NoteClick Advanced Settings to configure this parameter.
Page text assertion
The blocklist and allowlist for page text assertion. Valid values:
-
Page text blocklist: The characters that you expect not to appear on your page.
-
Page text allowlist: The only characters that you expect to appear on your page.
NoteClick Advanced Settings to configure this parameter.
Resource blocklist
Prevents specified resources from being loaded.
NoteClick Advanced Settings to configure this parameter.
-
-
Define assertions
The default availability condition is used for the assertion (Time to First Byte is less than 1,000 ms).
You can set multiple availability conditions. The test result is considered available only when all conditions are met. To add more conditions, click Add Availability Group. Multiple condition groups are evaluated with AND logic.
-
Select agents
Use the default agents.
-
Configure alerts
The default alert rule for availability rate is used.
Cloud Monitor provides a default alert rule. If it does not meet your requirements, follow these steps to add a new rule.
-
Click Add Rule.
-
Configure the parameters for the rule description.
Parameter
Description
Rule name
The name of the alert rule.
Metric name
The metric that triggers the alert. Valid values:
-
availability rate
-
First Contentful Paint
-
element error count
-
total download time
Comparison
The comparison operator for the threshold. Valid values:
-
>=
-
>
-
<=
-
<
-
=
-
!=
-
Increase from the same time yesterday
-
Decrease from the same time yesterday
-
Increase from the same time last week
-
Decrease from the same time last week
-
Increase from the previous period
-
Decrease from the previous period
Threshold and alert level
The alert level and its corresponding threshold.
The notification methods for each alert level are as follows:
-
Critical: Phone calls, SMS messages, email, and WebHook.
-
Warn: SMS messages, email, and WebHook.
-
Info: Email and WebHook.
The notification method for the Info alert level is Email and WebHook.
The number of consecutive periods the threshold must be breached before an alert is triggered. Valid values: 1, 2, 3, 4, 5, 10, 15, and 20.
Tag
The key and value of the tag for the alert rule.
Auto Scaling
If you enable Auto Scaling, Cloud Monitor triggers the associated scaling rule when an alert occurs. You must specify the Region, ESS Group, and ESS Rule.
Simple Log Service
If you enable Simple Log Service, Cloud Monitor sends alert data to a Logstore in Simple Log Service (SLS) when an alert occurs. You must specify the Region, ProjectName, and Logstore.
Message Service (MNS) topic
If you enable Simple Message Queue (formerly MNS) - Topic, Cloud Monitor sends alert data to a Message Service (MNS) topic when an alert occurs. You must specify the region and topic.
Function Compute
If you enable Function Compute, Cloud Monitor sends alert notifications to Function Compute (FC) for custom formatting when an alert occurs. You must specify the region, service, and function.
-
-
Click OK.
-
-
Configure alert contact groups
Select an alert contact group and keep the default values for the parameters under Advanced Settings.
Parameter
Description
Alert contact group
The alert contact groups to which alert notifications are sent. You must select at least one alert contact group.
Notifications are sent to all contacts in the selected groups. Each group can contain one or more alert contacts.
Mute period
The interval at which an alert notification is resent after an alert is triggered but not resolved. Valid values: 5 minutes, 15 minutes, 30 minutes, 60 minutes, 3 hours, 6 hours, 12 hours, and 24 hours.
After an alert is triggered, no additional notifications are sent during the mute period. If the metric remains abnormal after the mute period, Cloud Monitor sends another notification.
NoteClick Advanced Settings to configure this parameter.
Effective period
The period during which the alert rule is active. Monitoring data is checked and alerts are sent only during this period.
NoteClick Advanced Settings to configure this parameter.
Alert callback
A publicly accessible URL that receives alert data from Cloud Monitor via HTTP POST requests. Only HTTP is supported. Use threshold-based alert callbacks.
To test connectivity to the callback URL:
-
Click Test, located directly to the right of the callback URL.
In the WebHook Test panel, check the HTTP status code and test result details to verify connectivity.
NoteYou can also set the Test Template Type: and Language:. Then click Test again to view updated test results.
-
Click Close.
NoteClick Advanced Settings to configure this parameter.
-
-
-
Click Save and Edit Script.
-
-
(Optional) Load the Cloud Monitor browser test extension in Google Chrome.
NoteThis step is required only when you use the script recording feature for the first time.
-
On the Record Script page, click Local Installation.
The installation package for the Cloud Monitor browser test extension is downloaded.
-
Decompress the downloaded package.
-
In Google Chrome, enter
chrome://extensions/in the address bar. -
On the Extensions page, enable Developer mode in the upper-right corner. Then, click Load unpacked, select the decompressed extension folder, and click Select Folder.
The Cloud Monitor browser test extension appears in the list of loaded extensions.
-
Refresh the Record Script page.
The Taobao page is displayed in the script recording area on the right, where you can record your actions.
-
-
On the Record Script page, assert the website's loading integrity.
This example asserts that an image on the Taobao website is displayed correctly.
-
In the upper-left corner, click Assertion.
-
In the Detect Page Elements section, click Test whether an element exists.
-
In the recording area on the right, click the target image on the Taobao website.
After you click the target image, the test step configuration dialog box opens. The step name is set to Test img is present, and the target element area displays the HTML
imgtag of the selected image. Cloud Monitor automatically generates a locator to identify the target element. If the locator is unreliable, specify a custom one. For example, under User-specified locator, select css as the locator type. Confirm the settings and click Save.
-
-
View the browser test results.
On the Monitoring Tasks tab, click the name of the target task to view its results.
For failed test runs, click Details in the Actions column. Then, on the Details Analysis page, click the Detailed Steps tab to view the specific steps and the cause of the failure.