HeadSpin Documentation
Documentation

Browser Automation

Overview

HeadSpin's Browser Automation allows you to run Selenium scripts on browsers on real computer machines connected to Pboxes. If your org has access to Performance Sessions, the data from these browser sessions can also be recorded and examined in the Performance Sessions tab.

Currently all browsers run on macOS machines; support for Windows and Linux machines are coming soon.

Automation Configuration

To start automation on a browser, you first need to get the browser's Automation Configuration. Available browsers can be found in the Remote Control > Devices tab. Each browser appears on its own row, similar to device rows. If you don't see any browser available, please contact the HeadSpin support team for access.

view browsers

Each browser row includes basic information about the browser version (listed under the "OS" column). To see a browser's Aumation Configuration settings, click on its row More Actions symbol and select Automation Configuration.

autoconfig

The Automation Configuration dialog will pop up. From this dialog, you can copy the Web Driver URL and capabilities for this browser. This configuration can be used with the HeadSpin Appium IDE or Selenium Scripts.

Browser Automation with HeadSpin Appium IDE

To use browser automation with the HeadSpin Appium IDE, you will need to download the IDE (version 1.16.0 or above) through the Settings and Downloads page, accessed by clicking on your username in the upper-right corner and then clicking the blue 'Settings' button.

Once the IDE has been installed, open it to see the UI below. Copy the Web Driver URL and the capabilities into the IDE. By default, the session will not be recorded. To record the session and capture network data, add <code class="dcode">"headspin:capture": true</code> as a capability.

appium ide 1

HeadSpin Appium IDE 1.16.0 and above support additional action types: <code class="dcode">web</code> and <code class="dcode">context</code>. These are typical actions performed in a browser, such as navigating to a URL. To see the available actions, once the session has been started, click on Actions and then choose Web from the dropdown.

appium ide 2

The supported actions will appear.

appium ide 3

Browser Automation with Selenium Scripts

For a wider set of actions and more test automation, the browser configuration can be used to configure Selenium scripts. Below is an example of a simple Selenium script in Python.


from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

# The web driver URL from the automation configuration
url = 'https://us-mvo.headspin.io:9090/v0/1cbdf58968b14f7dbb3e5fe4e045fc36/wd/hub'

# the capabilities from the automation configuration
capabilities = {
    "browserVersion": "70.0.1",
    "browserName": "firefox",
    "headspin:capture": True # Add this capability to capture data in a performance session
}

# Initiate a connection with the specified URL and capabilities
driver = webdriver.Remote(command_executor=url, desired_capabilities=capabilities)

driver.title # Get the title
driver.get('http://google.com') # Open the URL
driver.quit() # close the session

Time Between Commands

The default time the server will wait for a new command is 60 seconds. Once a session has been established, and after every command is sent, if there is no new command within 60 seconds, the session will end. This value can be adjusted with the capability <code class="dcode">headspin:newCommandTimeout</code>. For example:


capabilities = {
    "browserVersion": "70.0.1",
    "browserName": "firefox",
    "headspin:capture": True, # Add this capability to capture data in a performance session
    "headspin:newCommandTimeout": 120
}

Watching Live Browser Automation Sessions

When there's a live session on a browser, the Start button to the left of the browser icon will turn into the magnifying glass, as shown in the screenshot below.

magnifying glass

Anyone in your team can click on the magnifying glass to view the browser UI and the automation logs in real time.

live logs

Viewing Browser Automation Performance Sessions

Sessions recorded with <code class="dcode">"headspin:capture"</code>: true will show up in the Performance Sessions tab, in the session list.

session 1

Both the Waterfall UI and the Issue UI are available for these sessions. Click on a UI to view the captured data.

session 2