Constructing a video link to record all screenshots during automation in BrowserStack

Notes: 
  1. Assign your username and access key to local variables.

                         name	   value
    local variable	username      joedoe
    
    	              name	   value
    local variable	accesskey     yD5fLNLwqYeyt7eAD5q2
    
  2. Apply the execute command action to query the builds associated with your username and access key.

    
    	               command	                                                                                       variable   timeout
    execute command	# "curl -u " & username & ":" & accesskey & " https://www.browserstack.com/automate/builds.json"     output     30
    

    The returned output will resemble as follows.

    
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    
      0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
      0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
      0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
    100   137  100   137    0     0     59      0  0:00:02  0:00:02 --:--:--    59
    [{"automation_build":{"name":"Untitled Build","duration":null,"status":"failed","hashed_id":"4985725de82332b74abcd1520449b364fab3b674"}}]
    
  3. Apply string functions and the get json query result action to parse the returned output and retrieve the build ID, which is hashes_id in the output.

    	                 name	value	
    local variable	   startLoc   #instr(output, "{", 1)	
    
    	                 name	value	
    local variable	   json	#mid(output, startLoc, length(output)-startLoc-1)	
    
    	                 json	jsonpath	               variable
    get json query result   #json      automation_build.hashed_id    >>build_id
    
  4. Retrieve the session ID of the target cloud device by using the connect device action.

    		            url	                                                                           capabilities	                                                                                     name
    assign device	    # "https://" & username & ":" & accesskey & "@hub-cloud.browserstack.com/wd/hub"     {"name":"TestArchitect - test gmail","browserName": "iPhone","device": "iPhone 5S","platform": "MAC"}   cloud_device
    
    	                   name	     session id	
    connect device         cloud_device    >>session_id	
    
  5. Create a user-defined field to build a video link which captures entire automated tests in BrowserStack.

    For example, create a field Screenshot Recording. (Learn more.)

  6. Use the assign result field action to assign the video link’s value to the Screenshot Recording field.

    This link is built based on the target device’s session ID and build ID.

    	                session id	
    use device	#session_id	
    
    	               location	   window
    navigate	       www.google.com	
    
    	               field	             value
    assign result field   Screenshot Recording     #"https://www.browserstack.com/automate/builds/"& build_id &"/sessions/"& session_id
    

The test procedure should resemble the following.

In the test result, you will see a video link as follows.


Copyright © 2023 LogiGear Corporation. All rights reserved. LogiGear is a registered trademark, and Action Based Testing and TestArchitect are trademarks of LogiGear Corporation. All other trademarks contained herein are the property of their respective owners.

LogiGear Corporation

1730 S. Amphlett Blvd. Suite 200, San Mateo, CA 94402

Tel: +1(800) 322-0333