Robot Framework selenium grid example

This Robot Framework code example will get you a quick start using a selenium grid to run a single test. These code examples uses a Gridlastic selenium grid V3 for browser execution, see V4 examples.

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

Test Script


*** Settings ***

Library  SeleniumLibrary

*** Variables ***

    ...  browserName: chrome,
    ...  platform: WIN10,
    ...  platformName: windows,
    ...  version: latest,
    ...  username: USERNAME,
    ...  accessKey: ACCESSKEY,
    ...  video: True

${browser}          Chrome
${capabilities}     ${EMPTY.join(${_tmp})}

*** Keywords ***

Open Test Page
    Open browser  browser=${browser}
    ...  remote_url=${remote_url}
    ...  desired_capabilities=${capabilities}
   Maximize Browser Window

*** Test Cases ***

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

Output Video URL

from robot.libraries.BuiltIn import BuiltIn
import time

def output_video_url():
    session_id = BuiltIn().get_library_instance('SeleniumLibrary').driver.session_id

Run Test

robot selenium_grid_example.robot

Get a free account and launch your Gridlastic selenium grid demo, then run this code locally and test your grid!

NOTE: Gridlastic auto scaling requires all 3 test environment parameters platform, browser and browser version to be specified in each request in order to launch test nodes to fulfill test demand. Video recording is optional. See test environments for capabilities options.