or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

builtin-libraries.mdconfiguration-variables.mdcore-execution.mdindex.mdlibrary-development.mdparsing-model.md

builtin-libraries.mddocs/

0

# Built-in Libraries

1

2

Robot Framework includes a comprehensive set of standard test libraries that provide keywords for common testing tasks. These libraries are available without explicit imports and cover system operations, data manipulation, time handling, and test control flow.

3

4

## Capabilities

5

6

### BuiltIn Library

7

8

Core keywords available in all test suites without explicit import. Provides fundamental functionality for test control, variable handling, and basic operations.

9

10

```python { .api }

11

class BuiltIn:

12

"""

13

Robot Framework's core library providing fundamental keywords.

14

Always available without explicit import.

15

"""

16

17

# Variable operations

18

def set_variable(self, name, *values): ...

19

def set_global_variable(self, name, *values): ...

20

def set_suite_variable(self, name, *values): ...

21

def set_test_variable(self, name, *values): ...

22

def get_variable_value(self, name, default=None): ...

23

def variable_should_exist(self, name, msg=None): ...

24

def variable_should_not_exist(self, name, msg=None): ...

25

26

# Test control

27

def pass_execution(self, message="", *tags): ...

28

def fail(self, msg=None, *tags): ...

29

def fatal_error(self, msg=None): ...

30

def skip_if(self, condition, msg=""): ...

31

def continue_for_loop_if(self, condition): ...

32

def exit_for_loop_if(self, condition): ...

33

34

# Assertions

35

def should_be_equal(self, first, second, msg=None, values=True): ...

36

def should_not_be_equal(self, first, second, msg=None, values=True): ...

37

def should_contain(self, item1, item2, msg=None, values=True): ...

38

def should_not_contain(self, item1, item2, msg=None, values=True): ...

39

def should_be_true(self, condition, msg=None): ...

40

def should_be_empty(self, item, msg=None): ...

41

def should_not_be_empty(self, item, msg=None): ...

42

43

# Keyword operations

44

def run_keyword(self, name, *args): ...

45

def run_keyword_and_return_status(self, name, *args): ...

46

def run_keyword_and_ignore_error(self, name, *args): ...

47

def run_keyword_if(self, condition, name, *args): ...

48

def run_keywords(self, *keywords): ...

49

50

# Logging and output

51

def log(self, message, level="INFO", html=False, console=False): ...

52

def log_many(self, *messages): ...

53

def comment(self, *messages): ...

54

def set_log_level(self, level): ...

55

56

# Imports

57

def import_library(self, name, *args): ...

58

def import_resource(self, path): ...

59

def import_variables(self, path, *args): ...

60

61

# Time operations

62

def sleep(self, time_, reason=None): ...

63

64

# Conversions

65

def convert_to_string(self, item): ...

66

def convert_to_integer(self, item, base=None): ...

67

def convert_to_number(self, item): ...

68

def convert_to_boolean(self, item): ...

69

```

70

71

**Usage Examples:**

72

73

```python

74

# These keywords are used directly in Robot Framework test files:

75

76

# *** Test Cases ***

77

# Variable Operations Example

78

# Set Test Variable ${name} Robot Framework

79

# ${value}= Get Variable Value ${name}

80

# Should Be Equal ${value} Robot Framework

81

# Variable Should Exist ${name}

82

83

# Test Control Example

84

# Run Keyword If ${condition} Log Condition was true

85

# ${status}= Run Keyword And Return Status Some Keyword

86

# Run Keyword And Ignore Error Might Fail Keyword

87

88

# Assertion Example

89

# Should Be Equal ${actual} ${expected}

90

# Should Contain ${text} substring

91

# Should Be True ${number} > 0

92

```

93

94

### Collections Library

95

96

Keywords for working with Python lists and dictionaries, providing comprehensive collection manipulation capabilities.

97

98

```python { .api }

99

class Collections:

100

"""Keywords for handling lists and dictionaries."""

101

102

# List operations

103

def append_to_list(self, list_, *values): ...

104

def insert_into_list(self, list_, index, value): ...

105

def remove_from_list(self, list_, index): ...

106

def remove_values_from_list(self, list_, *values): ...

107

def reverse_list(self, list_): ...

108

def sort_list(self, list_): ...

109

def copy_list(self, list_): ...

110

def count_values_in_list(self, list_, value, start=0, end=None): ...

111

def get_from_list(self, list_, index): ...

112

def get_index_from_list(self, list_, value, start=0, end=None): ...

113

def get_length(self, item): ...

114

def get_slice_from_list(self, list_, start=0, end=None): ...

115

def list_should_contain_value(self, list_, value, msg=None): ...

116

def list_should_not_contain_value(self, list_, value, msg=None): ...

117

def lists_should_be_equal(self, list1, list2, msg=None): ...

118

119

# Dictionary operations

120

def set_to_dictionary(self, dictionary, *key_value_pairs): ...

121

def remove_from_dictionary(self, dictionary, *keys): ...

122

def get_from_dictionary(self, dictionary, key): ...

123

def get_dictionary_keys(self, dictionary): ...

124

def get_dictionary_values(self, dictionary): ...

125

def get_dictionary_items(self, dictionary): ...

126

def copy_dictionary(self, dictionary): ...

127

def dictionary_should_contain_key(self, dictionary, key, msg=None): ...

128

def dictionary_should_not_contain_key(self, dictionary, key, msg=None): ...

129

def dictionary_should_contain_value(self, dictionary, value, msg=None): ...

130

def dictionaries_should_be_equal(self, dict1, dict2, msg=None): ...

131

132

# Combined operations

133

def keep_in_dictionary(self, dictionary, *keys): ...

134

def pop_from_dictionary(self, dictionary, key, default=None): ...

135

```

136

137

### String Library

138

139

String manipulation and text processing keywords.

140

141

```python { .api }

142

class String:

143

"""Keywords for string manipulation and text processing."""

144

145

# Basic string operations

146

def get_length(self, item): ...

147

def should_be_string(self, item, msg=None): ...

148

def should_not_be_string(self, item, msg=None): ...

149

def should_be_lowercase(self, string, msg=None): ...

150

def should_be_uppercase(self, string, msg=None): ...

151

def should_be_titlecase(self, string, msg=None): ...

152

153

# String modification

154

def convert_to_lowercase(self, string): ...

155

def convert_to_uppercase(self, string): ...

156

def convert_to_title_case(self, string): ...

157

def strip_string(self, string, characters=None, mode="both"): ...

158

def split_string(self, string, separator=None, max_split=-1): ...

159

def split_string_from_right(self, string, separator=None, max_split=-1): ...

160

def join_strings(self, *strings): ...

161

def replace_string(self, string, search_for, replace_with, count=-1): ...

162

def replace_string_using_regexp(self, string, pattern, replace_with, count=-1): ...

163

164

# String searching and matching

165

def get_substring(self, string, start, end=None): ...

166

def should_contain_string(self, str1, str2, msg=None, ignore_case=False): ...

167

def should_not_contain_string(self, str1, str2, msg=None, ignore_case=False): ...

168

def should_start_with(self, str1, str2, msg=None, ignore_case=False): ...

169

def should_end_with(self, str1, str2, msg=None, ignore_case=False): ...

170

def should_match_regexp(self, string, pattern, msg=None, partial=False): ...

171

def should_not_match_regexp(self, string, pattern, msg=None, partial=False): ...

172

173

# Regular expressions

174

def get_regexp_matches(self, string, pattern, *groups): ...

175

def get_lines_containing_string(self, string, pattern, case_insensitive=False): ...

176

def get_lines_matching_pattern(self, string, pattern, case_insensitive=False): ...

177

def get_lines_matching_regexp(self, string, pattern, partial=False): ...

178

```

179

180

### OperatingSystem Library

181

182

Keywords for operating system and file system operations.

183

184

```python { .api }

185

class OperatingSystem:

186

"""Keywords for operating system and file system operations."""

187

188

# File operations

189

def create_file(self, path, content="", encoding="UTF-8"): ...

190

def file_should_exist(self, path, msg=None): ...

191

def file_should_not_exist(self, path, msg=None): ...

192

def file_should_be_empty(self, path, msg=None): ...

193

def file_should_not_be_empty(self, path, msg=None): ...

194

def get_file(self, path, encoding="UTF-8", encoding_errors="strict"): ...

195

def get_file_size(self, path): ...

196

def get_binary_file(self, path): ...

197

def append_to_file(self, path, content, encoding="UTF-8"): ...

198

def copy_file(self, source, destination): ...

199

def move_file(self, source, destination): ...

200

def remove_file(self, path): ...

201

def touch(self, path): ...

202

203

# Directory operations

204

def create_directory(self, path): ...

205

def directory_should_exist(self, path, msg=None): ...

206

def directory_should_not_exist(self, path, msg=None): ...

207

def directory_should_be_empty(self, path, msg=None): ...

208

def directory_should_not_be_empty(self, path, msg=None): ...

209

def copy_directory(self, source, destination): ...

210

def move_directory(self, source, destination): ...

211

def remove_directory(self, path, recursive=False): ...

212

def empty_directory(self, path): ...

213

def list_directory(self, path, pattern=None, absolute=False): ...

214

def list_files_in_directory(self, path, pattern=None, absolute=False): ...

215

def list_directories_in_directory(self, path, pattern=None, absolute=False): ...

216

def count_items_in_directory(self, path, pattern=None): ...

217

def count_files_in_directory(self, path, pattern=None): ...

218

def count_directories_in_directory(self, path, pattern=None): ...

219

220

# Path operations

221

def join_path(self, base, *parts): ...

222

def join_paths(self, base, *paths): ...

223

def normalize_path(self, path): ...

224

def split_path(self, path): ...

225

def split_extension(self, path): ...

226

def get_file_name(self, path): ...

227

def get_path_without_extension(self, path): ...

228

def should_exist(self, path, msg=None): ...

229

def should_not_exist(self, path, msg=None): ...

230

231

# Environment variables

232

def get_environment_variable(self, name, default=None): ...

233

def set_environment_variable(self, name, value): ...

234

def append_to_environment_variable(self, name, *values): ...

235

def remove_environment_variable(self, name): ...

236

def environment_variable_should_be_set(self, name, msg=None): ...

237

def environment_variable_should_not_be_set(self, name, msg=None): ...

238

def get_environment_variables(self): ...

239

def log_environment_variables(self, level="INFO"): ...

240

241

# Process operations

242

def run(self, command): ...

243

def run_and_return_rc(self, command): ...

244

def run_and_return_rc_and_output(self, command): ...

245

```

246

247

### Process Library

248

249

Keywords for running external processes and managing subprocesses.

250

251

```python { .api }

252

class Process:

253

"""Keywords for running processes and managing subprocesses."""

254

255

# Process execution

256

def start_process(self, command, *arguments, **configuration): ...

257

def run_process(self, command, *arguments, **configuration): ...

258

def is_process_running(self, handle=None): ...

259

def wait_for_process(self, handle=None, timeout="1 minute", on_timeout="continue"): ...

260

def terminate_process(self, handle=None, kill=False): ...

261

def terminate_all_processes(self, kill=False): ...

262

def get_process_id(self, handle=None): ...

263

def get_process_object(self, handle=None): ...

264

def get_process_result(self, handle=None, rc=False, stdout=False, stderr=False): ...

265

def switch_process(self, handle): ...

266

def split_command_line(self, args, posix=None): ...

267

def join_command_line(self, *args): ...

268

269

# Process results

270

def process_should_be_stopped(self, handle=None, error_message="Process is running."): ...

271

def process_should_be_running(self, handle=None, error_message="Process is not running."): ...

272

```

273

274

### DateTime Library

275

276

Keywords for handling dates, times, and time-based operations.

277

278

```python { .api }

279

class DateTime:

280

"""Keywords for handling date and time."""

281

282

# Current time

283

def get_current_date(self, time_zone="local", increment=0, result_format="timestamp", exclude_millis=False): ...

284

def get_time(self, format="timestamp", time_="NOW"): ...

285

286

# Date manipulation

287

def add_time_to_date(self, date, time, result_format=None, exclude_millis=False, date_format=None): ...

288

def subtract_time_from_date(self, date, time, result_format=None, exclude_millis=False, date_format=None): ...

289

def subtract_date_from_date(self, date1, date2, result_format="number", exclude_millis=False, date1_format=None, date2_format=None): ...

290

291

# Date conversion

292

def convert_date(self, date, result_format="timestamp", exclude_millis=False, date_format=None): ...

293

def convert_time(self, time, result_format="number", exclude_millis=False): ...

294

295

# Date formatting

296

def get_time_zone(self, as_string=True): ...

297

```

298

299

### Dialogs Library

300

301

Keywords for user interaction through dialog boxes (requires tkinter).

302

303

```python { .api }

304

class Dialogs:

305

"""Keywords for user interaction via dialogs."""

306

307

def execute_manual_step(self, message, default_error=""): ...

308

def get_value_from_user(self, message, default_value="", hidden=False): ...

309

def get_selection_from_user(self, message, *values): ...

310

def pause_execution(self, message="Test execution paused. Press OK to continue."): ...

311

```

312

313

### Screenshot Library

314

315

Keywords for taking screenshots during test execution.

316

317

```python { .api }

318

class Screenshot:

319

"""Keywords for taking screenshots."""

320

321

def take_screenshot(self, name="screenshot", width="800px"): ...

322

def take_screenshot_without_embedding(self, name="screenshot"): ...

323

def set_screenshot_directory(self, path): ...

324

```

325

326

### XML Library

327

328

Keywords for parsing, modifying, and validating XML documents.

329

330

```python { .api }

331

class XML:

332

"""Keywords for XML parsing and manipulation."""

333

334

# Parsing and saving

335

def parse_xml(self, source, keep_clark_notation=False): ...

336

def get_element(self, source, xpath="."): ...

337

def get_elements(self, source, xpath): ...

338

def get_child_elements(self, source, tag=None): ...

339

def save_xml(self, source, path, encoding="UTF-8"): ...

340

341

# Element operations

342

def get_element_text(self, source, xpath=".", normalize_whitespace=False): ...

343

def get_element_attribute(self, source, name, xpath=".", default=None): ...

344

def get_elements_texts(self, source, xpath, normalize_whitespace=False): ...

345

def element_text_should_be(self, source, expected, xpath=".", normalize_whitespace=False, message=None): ...

346

def element_text_should_match(self, source, pattern, xpath=".", normalize_whitespace=False, message=None): ...

347

def element_attribute_should_be(self, source, name, expected, xpath=".", message=None): ...

348

def element_attribute_should_match(self, source, name, pattern, xpath=".", message=None): ...

349

350

# Modification

351

def add_element(self, source, element, index=None, xpath="."): ...

352

def remove_element(self, source, xpath="", remove_tail=False): ...

353

def clear_element(self, source, xpath=".", clear_tail=False): ...

354

def copy_element(self, source, xpath="."): ...

355

def set_element_text(self, source, text=None, tail=None, xpath="."): ...

356

def set_element_attribute(self, source, name, value, xpath="."): ...

357

def remove_element_attribute(self, source, name, xpath="."): ...

358

def set_element_tag(self, source, tag, xpath="."): ...

359

360

# Structure validation

361

def elements_should_be_equal(self, source, expected, exclude_children=False, normalize_whitespace=False): ...

362

def elements_should_match(self, source, expected, exclude_children=False, normalize_whitespace=False): ...

363

def element_should_exist(self, source, xpath, message=None): ...

364

def element_should_not_exist(self, source, xpath, message=None): ...

365

```

366

367

### Telnet Library

368

369

Keywords for Telnet connections and automation (requires telnetlib).

370

371

```python { .api }

372

class Telnet:

373

"""Keywords for Telnet connections."""

374

375

def open_connection(self, host, alias=None, port=23, timeout=None, newline=None,

376

prompt=None, prompt_is_regexp=False, encoding="UTF-8",

377

encoding_errors="ignore", default_log_level="INFO"): ...

378

def login(self, username, password, login_prompt="login: ", password_prompt="Password: ",

379

login_timeout="1 minute", login_incorrect="Login incorrect"): ...

380

def write(self, text, loglevel=None): ...

381

def write_bare(self, text): ...

382

def write_control_character(self, character): ...

383

def read(self, loglevel=None): ...

384

def read_until(self, expected, loglevel=None): ...

385

def read_until_regexp(self, *expected): ...

386

def read_until_prompt(self, loglevel=None, strip_prompt=False): ...

387

def execute_command(self, command, loglevel=None, strip_prompt=False): ...

388

def close_connection(self, loglevel=None): ...

389

def close_all_connections(self): ...

390

def switch_connection(self, index_or_alias): ...

391

def get_connection(self, index_or_alias=None): ...

392

def get_connections(self): ...

393

```

394

395

### Remote Library

396

397

Library for Robot Framework's remote library interface.

398

399

```python { .api }

400

class Remote:

401

"""Library for connecting to remote Robot Framework library servers."""

402

403

def __init__(self, uri="http://127.0.0.1:8270", timeout=None): ...

404

405

# All keywords are dynamically provided by the remote server

406

def get_keyword_names(self): ...

407

def run_keyword(self, name, args, kwargs): ...

408

def get_keyword_arguments(self, name): ...

409

def get_keyword_documentation(self, name): ...

410

```

411

412

## Library Constants

413

414

```python { .api }

415

# Standard library names

416

STDLIBS = frozenset([

417

'BuiltIn', 'Collections', 'DateTime', 'Dialogs', 'Easter',

418

'OperatingSystem', 'Process', 'Remote', 'Screenshot',

419

'String', 'Telnet', 'XML'

420

])

421

```

422

423

## Usage Examples

424

425

**Import and Use Libraries:**

426

427

```robot

428

*** Settings ***

429

Library Collections

430

Library String

431

Library OperatingSystem

432

Library Process

433

434

*** Test Cases ***

435

Collections Example

436

${list}= Create List first second third

437

Append To List ${list} fourth

438

${length}= Get Length ${list}

439

Should Be Equal As Integers ${length} 4

440

List Should Contain Value ${list} second

441

442

String Processing Example

443

${text}= Set Variable Hello World

444

${upper}= Convert To Uppercase ${text}

445

Should Be Equal ${upper} HELLO WORLD

446

Should Start With ${text} Hello

447

${words}= Split String ${text}

448

Should Be Equal ${words}[0] Hello

449

450

File Operations Example

451

Create File /tmp/test.txt Test content

452

File Should Exist /tmp/test.txt

453

${content}= Get File /tmp/test.txt

454

Should Be Equal ${content} Test content

455

Remove File /tmp/test.txt

456

File Should Not Exist /tmp/test.txt

457

458

Process Execution Example

459

${result}= Run Process echo Hello from process

460

Should Be Equal As Integers ${result.rc} 0

461

Should Be Equal ${result.stdout} Hello from process\n

462

```

463

464

## Types

465

466

```python { .api }

467

# Collection types

468

List = list

469

Dictionary = dict

470

471

# File system types

472

Path = str

473

FileContent = Union[str, bytes]

474

FileSize = int

475

476

# Process types

477

ProcessHandle = str

478

ReturnCode = int

479

ProcessResult = object # Has .rc, .stdout, .stderr attributes

480

481

# Date/time types

482

Timestamp = str # ISO format: "2024-01-01T12:00:00.000"

483

TimeString = str # Human readable: "1 minute 30 seconds"

484

TimeZone = str # "UTC", "local", etc.

485

486

# XML types

487

XMLElement = object # ElementTree element

488

XPath = str # XPath expression

489

490

# Regular expression types

491

Pattern = str # Regular expression pattern

492

RegexpMatch = object # Match result

493

```