Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Robot automated test environment installation

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Briefly explain the installation idea, first install the language (python3), then install the package management tool (pip), and then the automation framework (robot) and lib plug-ins (requests, etc.). For some basic concepts, but explain more, for example, what is python, what is pip and other conceptual issues can be self-taught by Baidu, the installation environment is part of learning, you may encounter some errors, the environment is always special, try to feel more, try to solve it yourself, and don't miss the opportunity to understand python/robotframework.

Python3 installation

Download path: https://www.python.org/downloads/

It is recommended to install version 3.5 or above

Pip installation

Download path: https://pip.pypa.io/en/stable/installing/

Python3 install setup.py changes the pip mirror source

Due to the limitation of the city wall, the speed of the default pip source may be unbearable, so it is recommended to use the domestic high-quality pip source:

Aliyun http://mirrors.aliyun.com/pypi/simple/

Https://pypi.mirrors.ustc.edu.cn/simple/ of University of Science and Technology of China

Douban http://pypi.douban.com/simple/

Temporarily change the source method

Pip install web.py-I http://pypi.douban.com/simple-- trusted-host pypi.douban.com

Permanent change

Create or modify a configuration file (usually created)

The file of linux is in ~ / .pip/pip.conf

Windows at% HOMEPATH%\ pip\ pip.ini)

Sample contents of the file:

[global]

Index-url = http://pypi.douban.com/simple

[install]

Trusted-host=pypi.douban.com

Robotframework install python3-m pip install robotframework==3.0.2 verify python-- versionrobot-- version install requests plug-in pip install-U requestspip install-U robotframework-requests install database plug-in pip install robotframework-databaselibrarypip install pymysql install pycharm debug tool

The development of automation use cases requires the ability to develop code. In order to improve development productivity, a professional IDE tool is indispensable. Jetbrains has developed a series of IDE tools. There are different professional tools for python, java and front end. Pycharm is the best IDE tool for python.

Download and install: http://www.jetbrains.com/pycharm/

Such as the official website, jetbrains has developed a series of IDE tools for python, java and front-end.

Install the pycharm plug-in that supports robot

File-Perference-Plugins (different versions of plug-ins may be installed in different locations, take your time)

Search for the intelliBot plug-in. After the download and installation is complete, restart pycharm

Configure file types that support robot syntax

File-Preference-Editor-File types finds Robot Feature and supports * .robot files by default. If you want other files to also support it, add it below, such as * .txt configuration pycharm one-click debugging

Since robot is not a major compatible python framework, you can only use external tool options to use one-click debugging (frameworks such as django and Gulp can be configured directly for one-click debugging)

Add a method to run as testsuite (file)

File-Preference-External Tools

Name: Robot Run TestSuiteProgram: fill in the path to the newly installed robot executable Parameters:-d results $FileName$Working directory: $FileDir$ add the method to run as testcase (single use case)

File-Preference-External Tools

Name: Robot Run SingleTestCaseProgram: enter the path to the newly installed robot executable parameters:-d results-t "$SelectedText$" $FileName$Working directory: $FileDir$ to see if the configuration is valid

Create a test.robot file

Write two automation use cases:

* Test Cases * First test case log to console I am the first case > Second test case log to console I am the second case

Test by file

Keep the window in the test.robot file and run Robot Run TestSuite in Tools-Exteral Tools to see the execution results of two case

Test a use case

If you select Second test case alone and run Robot Run SingleTestcase in Tools-Exteral Tools, you can see that only the second case is executed. The following is an optional action python multi-environment method.

When you have multiple environments, and the environment depends on different versions, or different plug-in packages, you need to use a multi-environment approach.

Install virtualenvsudo pip install virtualenv to create a virtual environment virtualenv newenv

Alternatively, you can explicitly specify the environment as follows, otherwise it will be created according to the default environment

Virtualenv newenv-- python==python2.7virtualenv newenv-- python==python3.5 enter the virtual environment source newenv/.env/bin/activate exit the virtual environment deactivate to create a clean python environment

The environment created by the default command will contain the current full number of plug-ins. If you do not need it, or are afraid of causing unnecessary conflicts, you can use the parameters to get a clean environment.

Virtualenv-no-site-packages newenv

If you also want some basic modules, such as setup, pip, wheel, etc., you can use the following command

Virtualenv-distribute newenv

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report