GithubHelp home page GithubHelp logo

webdemo's Introduction

Web testing with Robot Framework and Selenium2Library

Robot Framework is a generic open source test automation framework and Selenium2Library is one of the many test libraries that can be used with it. In addition to showing how they can be used together for web testing, this demo introduces the basic Robot Framework test data syntax, how tests are executed, and how logs and reports look like.

Test case files as well as a resource file used by them are located in the login_test directory. Click file names below to see the latest versions online.

`valid_login.robot`_

A test suite with a single test for valid login.

This test has a workflow that is created using keywords in the imported resource file.

`invalid_login.robot`_

A test suite containing tests related to invalid login.

These tests are data-driven by their nature. They use a single keyword, specified with the Test Template setting, that is called with different arguments to cover different scenarios.

This suite also demonstrates using setups and teardowns in different levels.

`resource.robot`_

A resource file with reusable keywords and variables.

The system specific keywords created here form our own domain specific language. They utilize keywords provided by the imported Selenium2Library.

See Robot Framework User Guide for more details about the test data syntax.

After running tests you will get report and log in HTML format. Example files are also visible online in case you are not interested in running the demo yourself:

Preconditions

A precondition for running the tests is having Robot Framework and Selenium2Library installed, and they in turn require Python. Robot Framework installation instructions cover both Robot and Python installations, and Selenium2Library has its own installation instructions.

In practice it is easiest to install Robot Framework and Selenium2Library along with its dependencies using pip package manager. Once you have pip installed, all you need to do is running these commands:

pip install robotframework
pip install robotframework-selenium2library

Running tests

The test cases are located in the login_tests directory. They can be executed using the robot command:

robot login_tests

Note

If you are using Robot Framework 2.9 or earlier, you need to use the pybot command instead.

You can also run an individual test case file and use various command line options supported by Robot Framework:

robot login_tests/valid_login.robot
robot --test InvalidUserName --loglevel DEBUG login_tests

Run robot --help for more information about the command line usage and see Robot Framework User Guide for more details about test execution in general.

Using different browsers

The browser that is used is controlled by ${BROWSER} variable defined in `resource.robot`_ resource file. Firefox browser is used by default, but that can be easily overridden from the command line:

robot --variable BROWSER:Chrome login_tests
robot --variable BROWSER:IE login_tests

Consult Selenium2Library documentation about supported browsers. Notice also that other browsers than Firefox require separate browser drivers to be installed before they can be used with Selenium and Selenium2Library.

webdemo's People

Contributors

finspin avatar mihaiparvu avatar mikahanninen avatar pekkaklarck avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.