How to write Test Cases in Robot Framework with Selenium Library

15,606

Solution 1

I have found a Maven project of Robot Framework (RF) with Selenium2Library. The following are the steps to run:

Pre-requisite: Java (1.5 or newer), Maven

  1. Download "robotframework-selenium2library-java-master.zip" from the following URL:

    https://github.com/MarkusBernhardt/robotframework-selenium2library-java

  2. Unzip the folder

  3. Open console/command prompt and go to the folder unzipped at step 2
  4. Execute the maven command as: mvn clean install
  5. Observe the execution: Google page will be opened in FF and do according to the Test Cases written
  6. Observe the report on /target/robotframework-reports/report.html (the report is nice!!!)

[Note: It needs to analyse the folder and coding infrastructure. The codes are in src folder. It's important to understand the pom.xml]

The following link might be very helpful. There are step by step description how to write test cases in Getting Started section.

http://www.wallix.org/2011/07/26/how-to-use-robotframework-with-the-selenium-library/

Solution 2

It is not clear from your question what you're trying to achieve. Do you want to run Robot Framework from Java ? Do you want to define keywords in Java?

I suspect you are aiming at the wrong tool.

First, Robot Framework tests are written in human-like language. Phrases are defined by keywords that can be implemented either as user keywords using the built-in language or as external keywords using Python/Java classes.

Second, Robot Framework is a tool to write Acceptance Tests. In such kind of tests, you pick your entire system and stimulate it with certain input and expect and verify a certain output/behaviour.

Now, what is important is the system entry-point. If your system entry-point is an executable it is not relevant if the testing process is in Python or Java; because all the test has to do is starting a new program.

If you interact with your system using a Java library then you need to define external keywords in Java using the library.

If you want to run Robot Framework from Java (without the need to install Python):

java -jar robotframework-2.6.3.jar --help
java -jar robotframework-2.6.3.jar mytests.txt
java -jar robotframework-2.6.3.jar --variable name:value mytests.txt

You find the jar here: https://code.google.com/p/robotframework/downloads/list

You will need to write some test cases before. I suggest to use RIDE ( https://github.com/robotframework/RIDE ) as test editor, but you need to install Python to run it.

Share:
15,606
Koly
Author by

Koly

nothing

Updated on June 04, 2022

Comments

  • Koly
    Koly almost 2 years

    I have installed Robot Framework. I am searching for example Test Cases for Robot Framework using Selenium Library.

    I need a guideline to start writing TCs on Robot Framework. Help is appreciated.