← Winnitude! Search  ·  Reader Mode (667 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 114 LINKS

GitHub - robotframework/SeleniumLibrary: Web testing library for Robot Framework

Repository navigation

SeleniumLibrary
Public

About

Web testing library for Robot Framework

Topics

python robotframework selenium

Resources

Readme Apache-2.0 license

Contributing

Contributing Activity Custom properties

Stars

1.5k stars

Watchers

140 watching

Forks

787 forks Report repository
Branches

Tags
Go to Branches page Go to Tags page

Latest commit

 

History


2,719 Commits
View commit history for this file.

Folders and files

Name Name Last commit message Last commit date
.github .github    
atest atest    
docs docs    
src/ SeleniumLibrary src/ SeleniumLibrary    
utest utest    
.gitattributes .gitattributes    
.gitignore .gitignore    
BUILD.rst BUILD.rst    
CHANGES.rst CHANGES.rst    
CONTRIBUTING.rst CONTRIBUTING.rst    
COPYRIGHT.txt COPYRIGHT.txt    
LICENSE.txt LICENSE.txt    
MANIFEST.in MANIFEST.in    
README.rst README.rst    
VERSIONS.rst VERSIONS.rst    
gen_stub.py gen_stub.py    
issue_template.md issue_template.md    
pyproject.toml pyproject.toml    
requirements-dev.txt requirements-dev.txt    
requirements.txt requirements.txt    
selenium.bmp selenium.bmp    
setup.py setup.py    
tasks.py tasks.py    

Repository files navigation

SeleniumLibrary

Contents

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.10 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.

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:

About

Web testing library for Robot Framework

Topics

python robotframework selenium

Resources

Readme Apache-2.0 license

Contributing

Contributing Activity Custom properties

Stars

1.5k stars

Watchers

140 watching

Forks

787 forks Report repository

Releases

Packages

Used by

Contributors

Languages