BROWSER

Recording keywords

Recording keywords

Click through the page and get a reusable user keyword, written into your suite while you work. Record Keyword and Record Keywords in five minutes.

New in Browser 21.0.0 You click through the page; Browser writes what you did as a user keyword into your suite file — live, while you click, ready to call from any test.

Record Keyword with the name Find The Get Text Keyword — three clicks and a search become four Keyword Calls.

Keywords, not tests

A recorder that writes whole test cases produces long, brittle scripts nobody wants to maintain. Browser records one keyword at a time, from wherever your test happens to be: after the login, on the right page, with the right data. You decide what the test does and which keywords it needs; the recorder fills in the steps of one of them.

That changes how you use it:

  • You name the keyword while you record, so it reads like your test design — Add Product To Cart, not Test 17.
  • It starts where your test stands. The setup is code you already have; the recording begins after it.
  • Wrong steps are undone in place. Click the wrong thing, press Undo, carry on.
  • Values become arguments with a click, so the keyword is reusable from the first run — see Keyword arguments.

Your first recording

The recorder needs a browser you can see. Put Record Keyword where the keyword should start:

*** Settings ***Library    Browser*** Test Cases ***Look Up A Keyword    New Browser    chromium    headless=False    New Page       https://robotframework-browser.org    Record Keyword    Find The Get Text Keyword
Robot Framework8 linesUTF-8

Run it. The page opens with the recorder toolbar, already recording. Now do in the page what the keyword should do. Each action shows up in the toolbar as a Keyword Call the moment you make it:

#You do in the pageRecorded as
1Click Keywords in the headerClick on the Keywords link
2Click the search fieldClick on the search field
3Type Get TextFill Text with Get Text
4Click Get Text in the keyword listClick on that entry

Then click ✕ in the toolbar's header to end the recording. The test continues with its next line, and first-recording.robot now ends with the four Keyword Calls:

*** Keywords ***Find The Get Text Keyword    [Tags]    recorded    Click    role=link[name="Keywords"s]    Click    role=searchbox[name*="Filter keywords"i]    Fill Text    role=searchbox[name*="Filter keywords"i]    Get Text    Click    role=link[name*="Get Text 5"i]

The same happens on any page. A login on car.keyword-driven.de, recorded live — every click and every field becomes a Keyword Call the moment it happens:

Five Keyword Calls in eight seconds: the toolbar shows each one as it is written.

One keyword or a session

KeywordRecordsEnds with
Record Keyword with a nameExactly one keyword, named in the call. The toolbar records from the first moment.✕ in the toolbar
Record KeywordsAny number of keywords. Each is named and started in the toolbar, then saved; in between nothing is recorded, so you can move to the next starting point.✕ in the toolbar

Record Keyword fits a test that is missing one step. Record Keywords fits building a keyword library: walk through the application once and save a keyword at every stop. Both block until the recording ends, return the recorded text, and write into the suite file unless you say otherwise — see Where recorded keywords go.

${text} =    Record Keyword    Login As AdminRecord Keyword     Search Product    ${CURDIR}/shop.resourceRecord Keywords    ${CURDIR}/shop.resource

In this chapter