Robot Framework selenium 4 grid example

This Robot Framework code example will get you a quick start using a selenium 4 grid to run a single test with video recording.

The remote url, video url and grid credentials used in this code example is displayed after launching your Gridlastic selenium grid.

This script requires a minimum version 6 of the SeleniumLibrary.


Test Script

selenium_grid_example.robot

*** Settings ***

Library  SeleniumLibrary
Library  output_video_url.py

*** Variables ***

${remote_url}       https://USERNAME:ACCESS_KEY@SUBDOMAIN.gridlastic.com/wd/hub

*** Keywords ***

Open Test Page
   &{GRIDLASTIC_OPTIONS}    Create Dictionary
    ...    video=true
    &{DESIRED_CAPABILITIES}    Create Dictionary
    ...    browserName=chrome
    ...    platformName=win10
    ...    browserVersion=latest
    ...    gridlastic:options=&{GRIDLASTIC_OPTIONS}
    Open Browser    https://gridlastic.com/?demo
    ...    remote_url=${remote_url}
    ...    desired_capabilities=${DESIRED_CAPABILITIES}
    Maximize Browser Window
    Sleep    10s


*** Test Cases ***

Run Test
    Open Test Page
    output video url
    [Teardown]  Close Browser	

Output Video URL

output_video_url.py

from robot.libraries.BuiltIn import BuiltIn
import time

def output_video_url():
    session_id = BuiltIn().get_library_instance('SeleniumLibrary').driver.session_id
    BuiltIn().log_to_console("VIDEO_URL=https://s3-us-west-1.amazonaws.com/........./play.html?"+session_id)
    time.sleep(15)

Run Test

robot selenium_grid_example.robot