Foreword
Robot Framework is an automated functional testing framework written a python. Good scalability, support keyword-driven, you can simultaneously test multiple types of client interfaces or can be distributed test execution. Mainly used for a lot of acceptance testing and acceptance test-driven development round (ATDD), support python, java programming languages (Baidu Encyclopedia). Gong For good work must first sharpen his tools before learning RF also need to setup the development environment, including the operational environment to build, build web automated testing environment, so today will explain three kinds of structures --RIDE RF test environment, Pycharm and Eclipse, you can choose what to do RF automated test environments according to their preferences
python installation
Since we mainly use python development environment RF script, so python installation is essential, but today, but more reports, many online tutorials, the installation process is very simple
Browser driver installation
Browsers and browser-driven installation is to do web automated testing essential part, of course, it was still omitted configuration steps, still a lot of online tutorials, provide a link to download Chrome-driven
https://npm.taobao.org/mirrors/chromedriver
RIDE environment configuration
Installation RIDE
RIDE general is a tool to develop the habit of using RF script for beginners, with a graphical interface, easy to use, without having to write python code manually, learning cost is relatively low, and the installation is very simple!
Open the CMD, the Executive pip3 install robotframework-ride command to
After installing the RIDE, we open the Script directory of the python installation directory, you will find more than a ride.py and robot.exe file
ride.py is RIDE GUI startup procedures, we can double-click to start it and see whether the open RIDE GUI interface, the following screen appears after open, indicating RIDE tool has been installed successfully, it is not very simple?
doubt
1. Some students may have a question, why so complicated to find online tutorials, but also to install wxPython, robotframework library?
A: If you use the RIDE tools more dependent libraries do need to install, because wxPython RIDE GUI is implemented using RF frame but also rely robotframework library, I do not have to install a separate, because at the time of installation robotframework-ride, pip have you installed these dependencies ^ - ^, do not believe you can look at the front of shots, if you re-installation process does not install automatically species depend on the environment, then install it manually using pip order these libraries can
2. After installing the RIDE, but not open the GUI page, how do?
A: Because the execution ride.py need to use the python interpreter, set about the implementation ride.py file for python interpreter can
Installation seleniumlibrary
seleniumlibrary library is based on selenium do secondary package library, mainly for use in RF version, so you need to install in order to use RF implement a web automated testing
Open CMD execution pip3 install robotframework-seleniumlibrary command to
Similarly, when installing this library, selenium will also be automatically installed, because robotframework-seleniumlibrary encapsulated selenium-based, automated testing of implementing a web for the RF frame dependencies
ok, so far, all environments have been installed, we can write a simple script to test whether there are environmental problems
Environmental Testing
How specific scripting, will not be discussed here, I just wrote an open browser to visit Baidu home page of a script
If you see the following output information and the browser is opened successfully then state your environment has been set up successfully, you can learn how to use RF to write automated test scripts
Results of the
summary
RIDE For starters, it is quite easy to use, you can view the use of keywords, scripting can be done by way of completing the form, you can write code directly, but not smart tips, it will not auto-complete code to write more tired
Pycharm environment configuration
As a developer focused on python language, most prefer to use the IDE of choice is pycharm, because he is powerful, such as debugging, syntax highlighting, Project management, code branches, IntelliSense, auto-complete, unit testing, version control. In addition, the IDE provides some advanced features, support for professional Web development under the Django framework, since a long time, you may form a dependency, no matter what developers want to use pycharm, because you already know enough about it and fell in love with it, then do not use the RF automation can pycharm Ne? Of course, such a powerful tool for doing not Ne? Then we explain how to use the RF pycharm build a web automated testing environment
Before using the web to do pycharm configure RF automated test, also need to install selenium, robotframework, robotframework-seleniumlibrary, browsers and browser driver does not need robotframework-ride, you can install the following way
pip3 install selenium
pip3 install robotframework
pip3 installl robotframework-seleniumlibrary
Since I mentioned above when configuring RIDE already installed, so you do not need to install the next several libraries of
pycharm installation
Installation steps will not repeat them here, Baidu piles, piles also cracking method
IntelliBot plug-in installation
This plug-in for the main RF Pycharm able to recognize and write scripts to perform RF script
Open the top right corner of Pycharm- Click [File] - Select [Setting] - Click on [Plugins]
The search box to enter intelliBot, click on the image above Install, wait for the installation to complete
Pycharm need to restart after installing the plugin Note:
RF configuration file type identification
Also open [Setting] - Select [Editor] - Click on [File Types] - [Robot Feature] found to the right of the file list, and add all of the RF script file types
After you configure and save it
Suite and the Case of the running configuration
Because the RF test scripting framework can not use python interpreter to run, and it has its own script execution robot.exe, installed automatically when the program re-execution pip3 install robotframework, under the script directory exists in python installation directory
Configuration Suite
Open the Settings pycharm - Select [Tools] - [External Tools] select the right window, click [+] number and fill in the following configuration information
name: free to take the name, but it is better to write the name in accordance with the picture, see the name EENOW
Program: the directory where the program robot.exe
Arguments: -d directory name to store the name of the report to specify the report (the system automatically named the name of the report)
Working directory: The current project directory
After the configuration saved
Configuration Case
Step provided above, the following information to fill in the configuration of FIG.
Arguments: -t represents the test case execution behind the mouse to select (Note: You need to select the test case name, rather than put the mouse on the use case name)
Run a use case
After configuring the above setting, select a project test suite or suite selected single test case name, right click and choose [External Tools] - select the corresponding implementation of test cases can be executed or suite
Environmental Testing
Also use pycharm write a Open a browser to access Baidu home page of the script, and then select Run test suites and test cases were run single, look at the success
script
Settings *** *** Library SeleniumLibrary *** *** the Test Cases to open the browser SeleniumLibrary.Open Browser HTTPS: //www.baidu.com Firefox
When running the script, if you see the browser normally open, and output information in the test kit or by all, represents a successful environment configuration
summary
Pictures, you can see, pycharm does not automatically identify RF in some libraries (not all identified with a red wavy line), then it is not smart tips, you can not see the use of RF in keywords, so overall, RF write scripts using pycharm more tired, does not recognize right and wrong code is written only by being given the information the investigation, of course, to fully grasp the big brother of all the keywords you can use it or not use the system only uses its own keywords You can use a keyword through the python code implementation
Eclipse environment to build
Prior to set up an Eclipse integrated RF alone do web automated testing, also need to install selenium, robotframework, robotframework-seleniumlibrary, browsers and browser driver does not need robotframework-ride
Install the JDK
Java JDK really everywhere, here is not to explain the JDK installation process, I believe that all developers, JDK installation has been essential to the
Installing Eclipse
download
I downloaded the 4.10 version, Eclipse Configuration RF the best choice for Mars (Eclipse version, code-named) above 4.5
After the download is complete extract to the specified directory, and then double-click to run Eclipse.exe and set up a working directory to run the Eclipse editor
Installation robotframework-ide
robotframework-ide is RED, Eclipse is running RF and RF script writing plug-ins, the following links are RED official website
Official website describes the RF way to configure Eclipse, you can refer to
Open the Eclipse- menu select [help] - [Click to install new software] - Click on [Add]
name: casual input
location: Enter http://master.dl.sourceforge.net/project/red-robot-editor/repository
add the following page will appear after
Direct all the way Next, the installation process will be prompted to restart Eclipse, you can restart
Configuration python version
After rebooting need to configure the installed robotframework the python interpreter
Open the [window] - Select [preferences]
Here interpreter will be automatically recognized, if not automatically recognize, you can manually add click Add, then click Apply and Close] to [
RF identification configuration, variable, keyword, auto-complete
Click [windows] - [preference] - [RobotFramework] - [Editor] - [Content Assitant] plus the following:
.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$@&*
Modify Eclipse Chinese encoding
Configuring python interpreter
If you do not intend to use Eclipse to write python script to run, then you can skip this step, but if you want to use python late development keywords, you can choose to install, write python interpreter Eclipse, plug-ins need to rely pyDev
Installation pyDev
The same way the original RED, open Eclipse- menu select [help] - [Click to install new software] - Click on [Add]
name: casual input
location: Enter http://pydev.org/updates
All the way Next, wait for the installation is complete, you will be prompted to restart Eclipse installation, you can choose to restart
After the restart, click [windows] - [preference] - [PyDev] - [Interpreters] - [Settings] Python Interpreter python interpreter, according to the following chart
Click [ok], select the corresponding directory after pop
Click [ok] After waiting loaded, saved all operations, then you can use Eclipse to create a python project, write python code
Environmental Testing
接下来我们就可以编写脚本验证一下我们的环境是否存在问题了,如何新键RF项目,编写RF脚本这里先不讲解,我还是使用之前编写的脚本,打开火狐浏览器访问百度首页来验证环境,如果环境没问题你会看到如下输入
总结
目前为止所有的能够编写RF脚本的3种环境都已配置完成,3个环境各自有各自的优缺点
RIDE:适合初学者,不喜欢写代码或者对代码不是很精通的测试人员,主要以填写表格的形式开发脚本
Pycharm:pycharm对RF脚本的支持不是很好,这也不能怪pycharm,因为配置RF的插件不给力,没那么多功能,使用起来不太友好
Eclipse:对于Eclipse来说,它的RF插件(RED)比较强大, 既可以支持表格形式编写脚本,又可以使用纯代码的方式编写脚本,支持代码自动补全,高亮显示,最主要一点可以查看所有的关键字的帮助文档,并且对于喜欢直接写RF脚本代码的同学来说,使用起来很友好
相关链接
RF官网:https://robotframework.org/ 以上所有的环境配置过程及插件你都能再官网找到