ITRS named a Visionary in the 2024 Gartner® Magic Quadrant™ for Digital Experience Monitoring

  1. Support
  2. Knowledge base
  3. Synthetic Monitoring
  4. Transaction monitoring
  5. Tutorial: User journey in a shop
  6. Shopping cart recording test script

Shopping cart recording test script

The following is the unedited script generated by the transaction recorder in the exercise Capturing the shopping cart user journey . If you didn’t make your own script using the tutorial, you can use this script to follow along in the testing and editing part of the tutorial.

To enter the script into your transaction monitor:

  1. Copy the code below.
  2. Open the Steps tab on your transaction monitor.
  3. Click the Switch to script button at the top right.
  4. Paste the code into the editor.
  5. Click Switch to visual editor.
{
  "steps": [ 
    {
      "name": "Go to start URL",
      "ignoreErrors": false,
      "recordWaterfall": false,
      "actions": [
        { "navigate": 
          {
            "url": "https://www.galacticshirts.com/"
          }
        }
      ]
    },
    {
      "name": "GalacticShirts.com - Shop cosmiclicious apparel",
      "ignoreErrors": false,
      "recordWaterfall": false,
      "collectPageSource": false,
      "actions": [
        {
          "click": {
            "element": {
              "xpath": "(//img[contains(@src,'https://www.galacticshirts.com/wp-content/uploads/2017/08/tshirt-suraya-300x300.png')])[1]",
              "alternatives": [
                {
                  "xpath": "(//img[contains(@src,'https://www.galacticshirts.com/wp-content/uploads/2017/08/tshirt-suraya-300x300.png')])[1]",
                  "name": "xpath:img"
                },
                {
                  "xpath": "(//main[@id='main']/section/div/ul/li/a/img)[1]",
                  "name": "xpath:idRelative"
                },
                {
                  "css": ".storefront-product-section:nth-child(2) .post-130 .attachment-woocommerce_thumbnail",
                  "name": "css:finder"
                }
              ],
              "shadowRoots": []
            }
          }
        }
      ]
    },
    {
      "name": "\"What Happens\" t-shirt | GalacticShirts.com",
      "ignoreErrors": false,
      "recordWaterfall": false,
      "actions": [
        {
          "set": {
            "value": "l",
            "isPassword": false,
            "element": {
              "css": "#pa_size"
            }
          }
        },
        {
          "click": {
            "element": {
              "css": "#pa_size" 
            },
            "description": "Click on an element \"Choose an option\""
          }
        },
        {
          "set": {
            "value": "2",
            "isPassword": false,
            "element": {
              "css": "input#quantity_6346b8b92ac97",
              "alternatives": [
                {
                  "css": "input#quantity_6346b8b92ac97",
                  "name": "id"
                },
                {
                  "css": "input[name=\"quantity\"]",
                  "name": "name"
                },
                {
                  "xpath": "(//input[@id='quantity_6346b8b92ac97'])[1]",
                  "name": "xpath:attributes"
                },
                {
                  "xpath": "(//div[@id='product-130']/div[2]/form/div/div[2]/div/input)[1]",
                  "name": "xpath:idRelative"
                },
                {
                  "css": "#quantity_6346b8b92ac97",
                  "name": "css:finder"
                }
              ],
              "shadowRoots": []
            },
            "description": "Set element (quantity_6346b8b92ac97) to '2'"
          }
        },
        {
          "click": {
            "element": {
              "css": "#quantity_5d3f4b334e9d1"
            },
            "description": "Click on an element (quantity_5d3f4b334e9d1)"
          }
        },
      {
        "click": {
          "element": {
            "css": "button.single_add_to_cart_button.button.alt"
          },
          "description": "Click on a button (Add to cart)"
        }
      },
      {
        "testDocumentContent": {
          "value": "added to your cart",
          "testType": "Contains",
          "description": "Content check"
        }
      },
      {
        "click": {  
          "element": {                
            "css": "div.woocommerce-message > a.button.wc-forward"              
          },              
          "description": "Click on a hyperlink (View cart)"            
        }          
      }        
    ]     
  },      
  {        
    "name": "Cart | GalacticShirts.com",        
    "ignoreErrors": false,        
    "recordWaterfall": false,        
    "actions": [          
      {            
        "set": {              
          "value": "1",              
          "isPassword": false,              
          "element": {                
            "css": "#quantity_5d3f4dbc85bab"              
          },              
          "description": "Set element (quantity_5d3f4dbc85bab) to '1'"            
        }          
      },          
      {            
        "click": {              
          "element": {                
            "css": "button[name=\"update_cart\"]"              
          },              
          "description": "Click on a button (Update cart)"            
        }          
      },          
      {            
        "testDocumentContent": {              
          "value": "Cart updated",              
          "testType": "Contains",              
          "description": "Content check"            
          }          
        },          
        {            
          "click": {              
            "element": {                
              "css": "a.remove"              
              },              
            "description": "Click on a hyperlink (×)"            
          }          
        },          
        {            
          "testDocumentContent": {              
          "value": "your cart is currently empty",              
          "testType": "Contains",              
          "description": "Content check"            
          }          
        }        
      ]      
    }    
  ]  
}
By using the Uptrends website, you consent to the use of cookies in accordance with our Cookie Policy.