Skip to main content

Web testing library for Robot Framework

Project description

Introduction

SeleniumLibrary is a web testing library for Robot Framework that utilizes the Selenium tool internally. The project is hosted on GitHub and downloads can be found from PyPI.

SeleniumLibrary currently works with Selenium 4. It supports Python 3.8 through 3.13. In addition to the normal Python interpreter, it works also with PyPy.

SeleniumLibrary is based on the “old SeleniumLibrary” that was forked to Selenium2Library and then later renamed back to SeleniumLibrary. See the VERSIONS.rst for more information about different versions and the overall project history.

https://img.shields.io/pypi/v/robotframework-seleniumlibrary.svg?label=version https://img.shields.io/pypi/dm/robotframework-seleniumlibrary.svg https://img.shields.io/pypi/l/robotframework-seleniumlibrary.svg https://github.com/robotframework/SeleniumLibrary/actions/workflows/CI.yml/badge.svg?branch=master

Keyword Documentation

See keyword documentation for available keywords and more information about the library in general.

Installation

The recommended installation method is using pip:

pip install --upgrade robotframework-seleniumlibrary

Running this command installs also the latest Selenium and Robot Framework versions. The --upgrade option can be omitted when installing the library for the first time.

It is possible to install directly from the GitHub repository. To install latest source from the master branch, use this command:

pip install git+https://github.com/robotframework/SeleniumLibrary.git

Please note that installation will take some time, because pip will clone the SeleniumLibrary project to a temporary directory and then perform the installation.

See Robot Framework installation instructions for detailed information about installing Python and Robot Framework itself. For more details about using pip see its own documentation.

Browser drivers

Browsers and drivers are installed and managed automatically by Selenium Manager. For more information, see the Selenium documentation.

Usage

To use SeleniumLibrary in Robot Framework tests, the library needs to first be imported using the Library setting as any other library. The library accepts some import time arguments, which are documented in the keyword documentation along with all the keywords provided by the library.

When using Robot Framework, it is generally recommended to write as easy-to-understand tests as possible. The keywords provided by SeleniumLibrary is pretty low level, though, and often require implementation-specific arguments like element locators to be passed as arguments. It is thus typically a good idea to write tests using Robot Framework’s higher-level keywords that utilize SeleniumLibrary keywords internally. This is illustrated by the following example where SeleniumLibrary keywords like Input Text are primarily used by higher-level keywords like Input Username.

*** Settings ***
Documentation     Simple example using SeleniumLibrary.
Library           SeleniumLibrary

*** Variables ***
${LOGIN URL}      http://localhost:7272
${BROWSER}        Chrome

*** Test Cases ***
Valid Login
    Open Browser To Login Page
    Input Username    demo
    Input Password    mode
    Submit Credentials
    Welcome Page Should Be Open
    [Teardown]    Close Browser

*** Keywords ***
Open Browser To Login Page
    Open Browser    ${LOGIN URL}    ${BROWSER}
    Title Should Be    Login Page

Input Username
    [Arguments]    ${username}
    Input Text    username_field    ${username}

Input Password
    [Arguments]    ${password}
    Input Text    password_field    ${password}

Submit Credentials
    Click Button    login_button

Welcome Page Should Be Open
    Title Should Be    Welcome Page

The above example is a slightly modified version of an example in a demo project that illustrates using Robot Framework and SeleniumLibrary. See the demo for more examples that you can also execute on your own machine. For more information about Robot Framework test data syntax in general see the Robot Framework User Guide.

Extending SeleniumLibrary

Before creating your own library which extends the SeleniumLibrary, please consider would the extension be also useful also for general usage. If it could be useful also for general usage, please create a new issue describing the enhancement request and even better if the issue is backed up by a pull request.

If the enhancement is not generally useful, example solution is domain specific, then the SeleniumLibrary offers public APIs which can be used to build its own plugins and libraries. Plugin API allows us to add new keywords, modify existing keywords and modify the internal functionality of the library. Also new libraries can be built on top of the SeleniumLibrary. Please see extending documentation for more details about the available methods and for examples how the library can be extended.

Community

If the provided documentation is not enough, there are various community channels available:

Project details


Release history Release notifications | RSS feed

This version

6.8.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robotframework_seleniumlibrary-6.8.0.tar.gz (171.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robotframework_seleniumlibrary-6.8.0-py3-none-any.whl (104.6 kB view details)

Uploaded Python 3

File details

Details for the file robotframework_seleniumlibrary-6.8.0.tar.gz.

File metadata

File hashes

Hashes for robotframework_seleniumlibrary-6.8.0.tar.gz
Algorithm Hash digest
SHA256 60fb0584b11eabc687e8433134093b764ec011e0e8a9ec417bfdeeab59d748bb
MD5 42362a738e7543e772e6fcbd8a417f26
BLAKE2b-256 2dd5aa063b493a14cdb2771c23e6d5fdaa90c3d4712f8a086077bc5595aae9b9

See more details on using hashes here.

File details

Details for the file robotframework_seleniumlibrary-6.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for robotframework_seleniumlibrary-6.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 96b34dedf151708b13ad4662c07f11ca7266c57c83129a0bb73a2afe27cdcba4
MD5 d5244561a9651a54ad95727591f4a15e
BLAKE2b-256 79bc40a8f377d245b543ec1b91f4fbab2fbdb9c497adbc48d2c864829cf3cc6e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page