Robot framework selenium grid example

Robot framework is supported by Gridlastic on your very own selenium grid in the cloud, run your tests at high speed on real browsers.

The Gridlastic hub endpoint and the video url used in this code example is displayed after launching your Gridlastic selenium grid (free).


Test Script

test.txt


*** Settings ***
Documentation               Robot Framework Example
...
Metadata                    VERSION     1.0
Library                     Selenium2Library
Library                     output_video_url.py
Test Setup                  Start browser
Test Teardown               Close All Browsers


*** Variables ***
${URL}                      https://www.google.com/ncr
${BROWSER}                  internetexplorer
${ALIAS}                    None
${REMOTE_URL}               http://USERNAME:ACCESS_KEY@SUBDOMAIN.gridlastic.com:80/wd/hub
${DESIRED_CAPABILITIES}     platform:VISTA,platformName:windows,video:True,version:11


*** Keywords ***
Start Browser
    [Documentation]         Start browser on Selenium Grid
    Open Browser            ${URL}  ${BROWSER}  ${ALIAS}  ${REMOTE_URL}  ${DESIRED_CAPABILITIES}
    Maximize Browser Window

*** Test Cases ***
Test Google
    [Documentation]         Test Google
    output video url
    Input Text    q    webdriver
    Submit Form
    Wait Until Page Contains    Searches related to webdriver
Note: starting from selenium version 3.9.1 you must also include "platformName": "windows" in the request when testing with firefox and IE.

Output Video URL

output_video_url.py


from robot.libraries.BuiltIn import BuiltIn

def output_video_url():
    session_id = BuiltIn().get_library_instance('Selenium2Library')._current_browser().session_id
    BuiltIn().log_to_console("VIDEO_URL=https://s3-us-west-1.amazonaws.com/........./play.html?"+session_id)

Run Test


pybot test.txt


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.