Robot framework automated testing (1) --- The first script

Source: Internet
Author: User

 

Recently, the tool used the robot Framework framework for automation, so it took some time to learn about it.

 

======= Required environment =============================

Python:

Https://www.python.org/

The RF framework is based on python, so you must have a python environment.

 

Robot framework:

Https://pypi.python.org/pypi/robotframework/2.8.5

This is not an explanation, RF framework. Although it shows a lot like qtp in UI-based automation, I thought it was similar to qtp before, and I knew that you would develop it to do a lot of things. Just like a beginner in selenium, they will mistakenly think selenium is selenium IDE.

 

Wxpython:

Http://www.wxpython.org/download.php

Wxpython is a very famous Python GUI library, because ride is developed based on this library, so this must be installed.

 

Robot framework-ride

Https://pypi.python.org/pypi/robotframework-ride

Ride is a graphic software used to create, organize, and run tests.

 

Robot framework-selenium2library:

Https://pypi.python.org/pypi/robotframework-selenium2library/1.5.0

The RF-seleniumlibrary can be seen as the selenium library of the RF version. Selenium (WebDriver) can be considered as a set of web-based specifications (APIs). Therefore, test tools such as RF and appium can be used to locate and operate pages based on this API.

----------------------

You can install Python using the PIP Toolkit:

> Pip install robotframework-selenium2library

 

If you contact the above items for the first time, you may feel that there are a lot of loaded items. If you have known Python or selenium before, you will not feel like this.

========================================================== ==========

After you have installed rf-ride, a ride icon is generated on the desktop. Double-click Start. The interface is as follows:

Next, we will create the first use case step by step. There is not much detail to explain, but we have a perceptual knowledge of writing use cases in the RF framework.

 

 

Create a test project

Choose file -----> new project

Name: Enter the project name.

Type Select Directory.

 

 

Create test suite

Right-click "test project" and choose new Suite Option

Name: Enter the project name.

Type: Select File.

 

 

Create Test Cases

Right-click "test project" and choose new test case

You only need to enter the use case name and click OK.

 

 

Import the selenium2library Library

Because the RF framework is used to compile web-based test cases, we need to support the selenium library. Therefore, we need to load the selenium2library library during use.

On the Edit tab of "test suite", click "library". The input box is displayed. Enter "name": selenium2library, and click "OK.

If the imported database is displayed in red, the imported database does not exist. If it is black, the import is successful.

 

 

Write Use Cases

Now we can start to write our use cases. But how can we write them? You can press the F5 shortcut to query the keyword of the script. If you have been familiar with automated tools such as qtp or selenium IDE, you should have some ideas.

For example, automated scripts are developed from open browsers. For example, if I want to open a browser, I want to search for the keyword "open", and a keyword "open browser" is found, click this keyword to display its usage and description.

According to the instructions, let's try to create this operation to open the browser:

"Open Browser" becomes blue, indicating that it is a valid keyword, followed by a box in red, indicating that this parameter cannot be set by default. Through instructions, I found that it requires a URL address which is mandatory. Of course, you also need to specify browser (friefox by default)

For more key usage instructions, see the relevant API documentation. I will not mention it here. Follow the above method. Use Cases for creating Baidu search are as follows:

 

 

Run Test Cases

Select the test case to be run and click the run button on the toolbar. If you only run a single case, you can switch to the run tab of the case and click the start button.

 

Running Information:

Three files are generated: output.xml‑log.html#report.html.

We need to record the execution process of log.html and report.html, while that of log.html. report.html is more focused on displaying the execution results of scripts.

Open your test report and check the results!

 

 

========================================================== ==========================================================

Error:

Command: pybot. bat -- argumentfile c: \ Users \ keikei \ appdata \ Local \ temp \ rideama2ym. d \ argfile.txt -- listener D: \ python27 \ Lib \ Site-packages \ robotide \ contrib \ testrunner \ testrunneragent. PY: 52418 E: robot \ test project

Solution:

Add "C: \ python27 \ scripts" to the path environment variable. Command Prompt symbol view, RF version. The prompt that pybot is not an internal command indicates that the environment variable settings are incorrect.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.